where is winepo script?

Post issues, bugs, and feature requests about the various WineHQ websites to this forum.
Locked
fcmartins
Level 4
Level 4
Posts: 114
Joined: Sat Nov 01, 2008 5:48 pm

where is winepo script?

Post by fcmartins »

I would like to work on translations, following https://wiki.winehq.org/Translating", but the winepo scrit link is broken and google doesn't find it elsewhere.

Anyone know where to find it?

Regards,
Fernando
User avatar
dimesio
Moderator
Moderator
Posts: 13201
Joined: Tue Mar 25, 2008 10:30 pm

Re: where is winepo script?

Post by dimesio »

I found a copy on the Internet Archive, though I don't know how up-to-date it is. Pasting it here because the forum doesn't allow attaching scripts.

Code: Select all

#!/bin/sh
# Copyright (C) 2012-2013 Francois Gouget
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA


#
# Logging and error reporting
#

name0=`basename "$0"`
error()
{
    echo "$name0:error:" "$@" >&2
}


#
# Command line processing
#

opt_po=""
usage=""
while [ $# -gt 0 ]
do
    arg="$1"
    shift
    case "$arg" in
    -\?|-h|--help)
        usage=0
        ;;

    -*)
        error "unknown option '$arg'"
        usage=2
        ;;

    *)
        if [ -z "$opt_po" ]
        then
            opt_po="$arg"
        else
            error "only one PO file can be processed at a time"
            usage=2
            break
        fi
        ;;
    esac
done

if [ -z "$usage" ]
then
    if [ -z "$opt_po" ]
    then
        error "you must specify the PO file to work on"
        usage=2
    fi
fi

if [ -n "$usage" ]
then
    if [ "$usage" != "0" ]
    then
        error "try '$name0 --help' for more information"
        exit $usage
    fi
    cat <<EOF
Usage: $name0 LOCALE.po

Gets, updates and diffs the specified Wine PO file.

Where:
  LOCALE.po     The PO file to work on.
  --help, -h    Shows this help message.
EOF
    exit 0
fi


# Make sure the state is sane

rm -f "$opt_po.diff"
if egrep "(<<<<<<<|=======|>>>>>>>)" "$opt_po" >/dev/null 2>&1
then
    error "you must resolve the conflicts before running $name0 again (look for '<<<<<<<')"
    if [ -f "$opt_po.old" ]
    then
        echo "As a last resort you will find a backup of your PO file in '$opt_po.old'." >&2
    fi
    exit 1
fi
if [ -f "$opt_po.old" ]
then
    # The conflicts have been resolved so there is no point keeping this backup
    rm "$opt_po.old"
fi
if [ -f "$opt_po" -a ! -f "$opt_po.orig" ]
then
    error "the unmodified '$opt_po.orig' file is missing. Cannot update the PO file"
    exit 1
fi

# Make sure the files have regular linefeeds
# (otherwise the diffs will be unusable)

if which fromdos >/dev/null 2>&1
then
    # This should not hurt if it's already the case.
    if [ -f "$opt_po.orig" ]
    then
        chmod u+w "$opt_po.orig"
        fromdos "$opt_po.orig"
        chmod a-w "$opt_po.orig"
    fi
    if [ -f "$opt_po" ]
    then
        fromdos "$opt_po"
    fi
fi
if LANG= file "$opt_po.orig" | grep "CRLF" >/dev/null
then
    error "the '$opt_po.orig' file has CRLF line endings"
    exit 1
fi
if LANG= file "$opt_po" | grep "CRLF" >/dev/null
then
    error "the '$opt_po' file has CRLF line endings"
    exit 1
fi

# Save the previous changes

if [ -f "$opt_po" ]
then
    cp "$opt_po" "$opt_po.old"
    diff -u "$opt_po.orig" "$opt_po" >"$opt_po.diff"
fi


# Download the latest updates

echo "Updating $opt_po..."
if ! wget --no-verbose -O "$opt_po.new" "http://source.winehq.org/git/wine.git/blob_plain/HEAD:/po/$opt_po"
then
    error "unable to download the latest version of '$opt_po'"
    rm -f "$opt_po.diff"
    exit 1
fi
[ -f "$opt_po.orig" ] && chmod u+w "$opt_po.orig"
mv "$opt_po.new" "$opt_po.orig"
cp "$opt_po.orig" "$opt_po"
chmod a-w "$opt_po.orig"


# Reapply the previous changes if any

if [ -f "$opt_po.diff" ]
then
    if ! patch --merge <"$opt_po.diff"
    then
        echo
        error "'$opt_po' contains conflict(s) that you must now resolve (look for '<<<<<<<', as a last resort you will find a backup of your PO file in '$opt_po.old')"
        rm "$opt_po.diff"
        exit 0
    fi
    echo
    echo "'$opt_po' has been updated successfully and is ready for edition."
    rm -f "$opt_po.old"
fi


# Generate a new diff

dirname=`dirname "$opt_po"`
cd "$dirname"
opt_po=`basename "$opt_po"`

tmpdir="winepo.tmp.$$"
mkdir -p "$tmpdir/a/po" "$tmpdir/b/po"
cp "$opt_po.orig" "$tmpdir/a/po/$opt_po"
cp "$opt_po" "$tmpdir/b/po/$opt_po"

(cd "$tmpdir" && diff -u "a/po/$opt_po" "b/po/$opt_po") >"$opt_po.diff"
rm -rf "$tmpdir"
if [ -s "$opt_po.diff" ]
then
    echo "'$opt_po.diff' is ready for submission to [email protected]."
else
    rm "$opt_po.diff"
    echo "When the translation is ready, run '$name0 $opt_po' again."
fi

exit 0
User avatar
dimesio
Moderator
Moderator
Posts: 13201
Joined: Tue Mar 25, 2008 10:30 pm

Re: where is winepo script?

Post by dimesio »

I also added it to the wiki page.
fcmartins
Level 4
Level 4
Posts: 114
Joined: Sat Nov 01, 2008 5:48 pm

Re: where is winepo script?

Post by fcmartins »

dimesio wrote:I also added it to the wiki page.
Thanks, it seems to be working well. I submitted a patch.
Could you also update the page to replace wine-patches with wine-devel list as it seems to be deprecated.
User avatar
dimesio
Moderator
Moderator
Posts: 13201
Joined: Tue Mar 25, 2008 10:30 pm

Re: where is winepo script?

Post by dimesio »

fcmartins wrote:Could you also update the page to replace wine-patches with wine-devel list as it seems to be deprecated.
I did that yesterday when I added the script to the page.
Locked