From 650517bba170d261ad4e07e4a0a62c0cf6c907a6 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 5 Apr 2013 02:22:21 +0300 Subject: [PATCH] Add syncronization of po-files with Transifex. Signed-off-by: Slava Zanko --- maint/send-po | 37 ---- .../sync-transifex/config.d/po/po-ignore.list | 2 + maint/sync-transifex/config.d/po/tx.config | 8 + maint/sync-transifex/po-fromTransifex.sh | 67 +++++++ maint/sync-transifex/po-toTransifex.sh | 50 ++++++ po/README.tools | 37 ---- po/statistics.pl | 30 ---- po/strip-location.sh | 8 - po/update.pl | 167 ------------------ po/update.sh | 74 -------- 10 files changed, 127 insertions(+), 353 deletions(-) delete mode 100755 maint/send-po create mode 100644 maint/sync-transifex/config.d/po/po-ignore.list create mode 100644 maint/sync-transifex/config.d/po/tx.config create mode 100755 maint/sync-transifex/po-fromTransifex.sh create mode 100755 maint/sync-transifex/po-toTransifex.sh delete mode 100644 po/README.tools delete mode 100755 po/statistics.pl delete mode 100755 po/strip-location.sh delete mode 100755 po/update.pl delete mode 100755 po/update.sh diff --git a/maint/send-po b/maint/send-po deleted file mode 100755 index 5bb2c637f..000000000 --- a/maint/send-po +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -# Generate mc.pot, upload it and *.po files to the FTP directory. - -set -e - -if ! test -d po; then - echo "Run this script in the top level source directory" >&2 - exit 1 -fi - -DOMAIN=mc -COPYRIGHT_HOLDER="Free Software Foundation, Inc." -XGETTEXT_OPTIONS="--keyword=_ --keyword=N_ --keyword=Q_" -XGETTEXT=xgettext -MSGMERGE=msgmerge - -files=`find . -name '*.[ch]' | xargs $XGETTEXT $XGETTEXT_OPTIONS --output=- | \ - sed -ne '/^#:/{s/#://;s/:[0-9]*/\n/g;s/ //g;p;}' | sort -u` - -$XGETTEXT --default-domain=$DOMAIN --directory=. \ - --add-comments=TRANSLATORS: $XGETTEXT_OPTIONS \ - --copyright-holder="$COPYRIGHT_HOLDER" --output=po/new-mc.pot $files - -for file in po/*.po; do - $MSGMERGE --output=po/new-`basename $file` $file po/new-mc.pot -done - -# Location of the snapshot directory -SITE="login.ibiblio.org" -DIR="/public/ftp/pub/Linux/utils/file/managers/mc/po" - -scp po/new-* "$SITE:$DIR/" - -ssh $SITE "cd $DIR; for file in new-*; do mv -f \$file \${file#new-}; done" - -rm -f po/new-* diff --git a/maint/sync-transifex/config.d/po/po-ignore.list b/maint/sync-transifex/config.d/po/po-ignore.list new file mode 100644 index 000000000..cc48e4838 --- /dev/null +++ b/maint/sync-transifex/config.d/po/po-ignore.list @@ -0,0 +1,2 @@ +it.po +ru.po diff --git a/maint/sync-transifex/config.d/po/tx.config b/maint/sync-transifex/config.d/po/tx.config new file mode 100644 index 000000000..78e2fa2f8 --- /dev/null +++ b/maint/sync-transifex/config.d/po/tx.config @@ -0,0 +1,8 @@ +[main] +host = http://www.transifex.net + +[mc.mcpot] +file_filter = .po +source_file = mc.pot +source_lang = en + diff --git a/maint/sync-transifex/po-fromTransifex.sh b/maint/sync-transifex/po-fromTransifex.sh new file mode 100755 index 000000000..b55a95118 --- /dev/null +++ b/maint/sync-transifex/po-fromTransifex.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# Midnight Commander - fetch doc/hints/mc.hint translations from Transifex +# +# Copyright (C) 2013 +# The Free Software Foundation, Inc. +# +# Written by: +# Slava Zanko , 2013 +# +# This file is part of the Midnight Commander. +# +# The Midnight Commander is free software: you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# The Midnight Commander 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(pwd)))} + +#*** include section (source functions, for example) ******************* + +source "${MC_SOURCE_ROOT_DIR}/maint/sync-transifex/functions" + +#*** file scope functions ********************************************** + +stripLocation() { + work_dir=$1; shift + + for i in $(find "${work_dir}" -name '*.po' -print); do + sed -i '/^#:/d' "${i}" + done +} + +# ---------------------------------------------------------------------- + +copyFilesToSourceDir() { + work_dir=$1; shift + source_dir=$1; shift + + exclude_list_file=$(getConfigFile "po" "po-ignore.list") + + for i in $(find "${work_dir}" -name '*.po' -print | sort); do + [ $(grep -c "^\s*$(basename ${i})" "${exclude_list_file}") -ne 1 ] && { + cp -f "${i}" "${source_dir}" + } + done +} + +#*** main code ********************************************************* + +WORK_DIR=$(initSyncDirIfNeeded "po") + +receiveTranslationsFromTransifex "${WORK_DIR}" + +stripLocation "${WORK_DIR}" + +copyFilesToSourceDir "${WORK_DIR}" "${MC_SOURCE_ROOT_DIR}/po" diff --git a/maint/sync-transifex/po-toTransifex.sh b/maint/sync-transifex/po-toTransifex.sh new file mode 100755 index 000000000..5ca1eb7d1 --- /dev/null +++ b/maint/sync-transifex/po-toTransifex.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +# Midnight Commander - push doc/hints/mc.hint file to Transifex +# +# Copyright (C) 2013 +# The Free Software Foundation, Inc. +# +# Written by: +# Slava Zanko , 2013 +# +# This file is part of the Midnight Commander. +# +# The Midnight Commander is free software: you can redistribute it +# and/or modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# The Midnight Commander 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +set -e + +MC_SOURCE_ROOT_DIR=${MC_SOURCE_ROOT_DIR:-$(dirname $(dirname $(pwd)))} + +#*** include section (source functions, for example) ******************* + +source "${MC_SOURCE_ROOT_DIR}/maint/sync-transifex/functions" + +#*** file scope functions ********************************************** + +copyPotToWorkDir() { + work_dir=$1; shift + source_dir=$1; shift + + cp -f "${source_dir}/mc.pot" "${work_dir}" +} + +#*** main code ********************************************************* + +WORK_DIR=$(initSyncDirIfNeeded "po") + +copyPotToWorkDir "${WORK_DIR}" "${MC_SOURCE_ROOT_DIR}/po" + +sendSourceToTransifex "${WORK_DIR}" + diff --git a/po/README.tools b/po/README.tools deleted file mode 100644 index 78787bf02..000000000 --- a/po/README.tools +++ /dev/null @@ -1,37 +0,0 @@ -The update.pl script is included here. This script should be run like -this: - - ./update.pl [OPTIONS] ...LANGCODE - -By default, this script updates the pot file (the po template generated -from the source code) and merges it with the po files (translations). - -For instance to do this for Danish, type the following - - ./update.pl da - - -The update.pl script also supports other options, they are: - - -V, --version shows the version - -H, --help shows this help page - -P, --pot only generates the potfile - -M, --maintain search for missing files in POTFILES.in - -Especially the --maintain option is very handy for package maintainers -to check if you included all the files that have marked strings in the -POTFILES.in, so they will be in the generated pot file (po template). - -You should make sure that the files found by the update.pl script are -either distributed or always create during the build process. Otherwise -"make distcheck" may fail preventing the release. - -The script supports the --help option for further help, though its not -very extensive for the moment. - -Kenneth Christiansen - -kenneth@gnu.org -kenneth@gnome.org - -update.pl is are copyright 2000 The Free Software Foundation and me. diff --git a/po/statistics.pl b/po/statistics.pl deleted file mode 100755 index 043ba94cb..000000000 --- a/po/statistics.pl +++ /dev/null @@ -1,30 +0,0 @@ -#! /usr/bin/env perl -use strict; -use warnings; - -my $first = 1; - -foreach my $f (@ARGV) { - my ($lang, $translated, $fuzzy, $untranslated) = (undef, 0, 0, 0); - - # statistics are printed on stderr, as well as error messages. - my $stat = `msgfmt --statistics "$f" 2>&1`; - ($lang = $f) =~ s,\.po$,,; - if ($stat =~ qr"(\d+)\s+translated") { - $translated = $1; - } - if ($stat =~ qr"(\d+)\s+fuzzy") { - $fuzzy = $1; - } - if ($stat =~ qr"(\d+)\s+untranslated") { - $untranslated = $1; - } - if ($first) { - printf("%8s %10s %5s %12s\n", - "language", "translated", "fuzzy", "untranslated"); - printf("%s\n", "-" x 43); - $first = 0; - } - printf("%8s %10d %5d %12d\n", - $lang, $translated, $fuzzy, $untranslated); -} diff --git a/po/strip-location.sh b/po/strip-location.sh deleted file mode 100755 index 7984bd84d..000000000 --- a/po/strip-location.sh +++ /dev/null @@ -1,8 +0,0 @@ -#! /bin/sh -set -e - -for i in "$@"; do - i="./$i" - sed '/^#:/d' < "$i" > "$i.tmp" - mv -f "$i.tmp" "$i" -done diff --git a/po/update.pl b/po/update.pl deleted file mode 100755 index 234cd3093..000000000 --- a/po/update.pl +++ /dev/null @@ -1,167 +0,0 @@ -#!/usr/bin/env perl -use warnings; - -# GNOME po update utility. -# (C) 2000 The Free Software Foundation -# -# Author(s): Kenneth Christiansen - - -$VERSION = "1.2.5 beta 2"; -$LANG = $ARGV[0]; -$PACKAGE = "mc"; - -if (! $LANG){ - print "update.pl: missing file arguments\n"; - print "Try `update.pl --help' for more information.\n"; - exit; -} - -if ($LANG=~/^-(.)*/){ - - if ("$LANG" eq "--version" || "$LANG" eq "-V"){ - print "GNOME PO Updater $VERSION\n"; - print "Written by Kenneth Christiansen , 2000.\n\n"; - print "Copyright (C) 2000 Free Software Foundation, Inc.\n"; - print "This is free software; see the source for copying conditions. There is NO\n"; - print "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"; - exit; - } - - - elsif ($LANG eq "--help" || "$LANG" eq "-H"){ - print "Usage: ./update.pl [OPTIONS] ...LANGCODE\n"; - print "Updates pot files and merge them with the translations.\n\n"; - print " -V, --version shows the version\n"; - print " -H, --help shows this help page\n"; - print " -P, --pot only generates the potfile\n"; - print " -M, --maintain search for missing files in POTFILES.in\n"; - print "\nExamples of use:\n"; - print "update.sh --pot just creates a new pot file from the source\n"; - print "update.sh da created new pot file and updated the da.po file\n\n"; - print "Report bugs to .\n"; - exit; - } - - elsif($LANG eq "--pot" || "$LANG" eq "-P"){ - - print "Building the $PACKAGE.pot ..."; - - $b="xgettext --default-domain\=$PACKAGE --directory\=\.\." - ." --add-comments=TRANSLATORS: --keyword\=\_ --keyword\=N\_" - ." --keyword\=Q\_ --files-from\=\.\/POTFILES\.in "; - $b1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot " - ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)"; - - `$b`; - `$b1`; - - print "...done\n"; - - exit; - } - - elsif ($LANG eq "--maintain" || "$LANG" eq "-M"){ - - $a="find ../ -type f -print | egrep '.*\\.(c|y|cc|c++|cxx|cpp|h|gob)\$' "; - - open(BUF2, "POTFILES.in") || die "update.pl: there is no POTFILES.in !!!\n"; - print "Searching for missing _(\" \") entries...\n"; - open(BUF1, "$a|"); - - - @buf2 = ; - @buf1 = ; - - if (-s "POTFILES.ignore"){ - open FILE, "POTFILES.ignore"; - while () { - if ($_=~/^[^#]/o){ - push @bup, $_; - } - } - print "POTFILES.ignore found! Ignoring files...\n"; - @buf2 = (@bup, @buf2); - } - - foreach my $file (@buf1){ - open FILE, "<$file"; - while () { - if ($_=~/_\s*\(\"/o){ - $file = unpack("x4 A*",$file) . "\n"; - push @buff1, $file; - last; - } - } - } - - @bufff1 = sort (@buff1); - - @bufff2 = sort (@buf2); - - my %in2; - foreach (@bufff2) { - $in2{$_} = 1; - } - - foreach (@bufff1){ - if (!exists($in2{$_})){ - push @result, $_ } - } - - if(@result){ - open OUT, ">POTFILES.in.missing"; - print OUT @result; - print "\nHere are the results:\n\n", @result, "\n"; - print "File POTFILES.in.missing is being placed in directory...\n"; - print "Please add the files that should be ignored in POTFILES.ignore\n"; - } - else{ - print "\nWell, it's all perfect! Congratulation!\n"; - } - } - - - else{ - print "update.pl: invalid option -- $LANG\n"; - print "Try `update.pl --help' for more information.\n"; - } - exit; - } - -elsif(-s "$LANG.po"){ - - print "Building the $PACKAGE.pot ..."; - - $c="xgettext --default-domain\=$PACKAGE --directory\=\.\." - ." --add-comments=TRANSLATORS: --keyword\=\_ --keyword\=N\_" - ." --keyword\=Q\_ --files-from\=\.\/POTFILES\.in "; - $c1="test \! -f $PACKAGE\.po \|\| \( rm -f \.\/$PACKAGE\.pot " - ."&& mv $PACKAGE\.po \.\/$PACKAGE\.pot \)"; - - `$c`; - `$c1`; - - print "...done"; - - print "\nNow merging $LANG.po with $PACKAGE.pot, and creating an updated $LANG.po ...\n"; - - - $d="mv $LANG.po $LANG.po.old && msgmerge --no-location $LANG.po.old $PACKAGE.pot -o $LANG.po"; - - $f="msgfmt --statistics $LANG.po"; - - `$d`; - `$f`; - - unlink "messages"; - unlink "$LANG.po.old"; - - exit; -} - -else{ - print "update.pl: sorry, $LANG.po doesn't exist!\n"; - print "Try `update.pl --help' for more information.\n"; - exit; -} diff --git a/po/update.sh b/po/update.sh deleted file mode 100755 index 75bdb49f4..000000000 --- a/po/update.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/sh - -PACKAGE="mc" - -if [ "x$1" = "x--help" ]; then - -echo Usage: ./update.sh langcode -echo --help display this help and exit -echo --missing search for missing files in POTFILES.in -echo -echo Examples of use: -echo ./update.sh ----- just creates a new pot file from the source -echo ./update.sh da -- created new pot file and updated the da.po file - -elif [ "x$1" = "x--missing" ]; then - -echo "Searching for files containing _( ) but missing in POTFILES.in..." -find ../ -regex '.*\.[c|y|cc|c++|h]' | xargs grep _\( | cut -d: -f1 | uniq | cut -d/ -f2- > POTFILES.in.missing - -echo Sorting... comparing... -sort -d POTFILES.in -o POTFILES.in -sort -d POTFILES.in.missing -o POTFILES.in.missing - -diff POTFILES.in POTFILES.in.missing -u0 | grep '^+' |grep -v '^+++'|grep -v '^@@' > POTFILES.in.missing - -if [ -s POTFILES.in.missing ]; then -echo && echo "Here are the results:" -echo && cat POTFILES.in.missing -echo && echo "File POTFILES.in.missing is being placed in directory..." - -else - -echo &&echo "There are no missing files, thanks God!" -rm POTFILES.in.missing - -fi - -elif [ "x$1" = "x" ]; then - -echo "Building the $PACKAGE.pot ..." - -xgettext --default-domain=$PACKAGE --directory=.. \ - --add-comments=TRANSLATORS: --keyword=_ --keyword=N_ \ - --keyword=Q_ --files-from=./POTFILES.in \ -&& test ! -f $PACKAGE.po \ - || ( rm -f ./$PACKAGE.pot \ -&& mv $PACKAGE.po ./$PACKAGE.pot ); - -else - -if [ -s $1.po ]; then - -xgettext --default-domain=$PACKAGE --directory=.. \ - --add-comments=TRANSLATORS: --keyword=_ --keyword=N_ \ - --keyword=Q_ --files-from=./POTFILES.in \ -&& test ! -f $PACKAGE.po \ - || ( rm -f ./PACKAGE.pot \ -&& mv $PACKAGE.po ./$PACKAGE.pot ); - -echo "Building the $PACKAGE.pot ..." -echo "Now merging $1.po with $PACKAGE.pot, and creating an updated $1.po ..." - -mv $1.po $1.po.old && msgmerge --no-location $1.po.old $PACKAGE.pot -o $1.po \ -&& rm $1.po.old; - -msgfmt --statistics $1.po - -else - -echo Sorry $1.po does not exist! - -fi; - -fi;