mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 12:32:40 +03:00
Add syncronization of po-files with Transifex.
Signed-off-by: Slava Zanko <slavazanko@gmail.com>
This commit is contained in:
parent
97097d1667
commit
650517bba1
@ -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-*
|
2
maint/sync-transifex/config.d/po/po-ignore.list
Normal file
2
maint/sync-transifex/config.d/po/po-ignore.list
Normal file
@ -0,0 +1,2 @@
|
||||
it.po
|
||||
ru.po
|
8
maint/sync-transifex/config.d/po/tx.config
Normal file
8
maint/sync-transifex/config.d/po/tx.config
Normal file
@ -0,0 +1,8 @@
|
||||
[main]
|
||||
host = http://www.transifex.net
|
||||
|
||||
[mc.mcpot]
|
||||
file_filter = <lang>.po
|
||||
source_file = mc.pot
|
||||
source_lang = en
|
||||
|
67
maint/sync-transifex/po-fromTransifex.sh
Executable file
67
maint/sync-transifex/po-fromTransifex.sh
Executable file
@ -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 <slavazanko@gmail.com>, 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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"
|
50
maint/sync-transifex/po-toTransifex.sh
Executable file
50
maint/sync-transifex/po-toTransifex.sh
Executable file
@ -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 <slavazanko@gmail.com>, 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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}"
|
||||
|
@ -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.
|
@ -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);
|
||||
}
|
@ -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
|
167
po/update.pl
167
po/update.pl
@ -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 <kenneth\@gnome.org>, 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 <kenneth\@gnome.org>.\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 = <BUF2>;
|
||||
@buf1 = <BUF1>;
|
||||
|
||||
if (-s "POTFILES.ignore"){
|
||||
open FILE, "POTFILES.ignore";
|
||||
while (<FILE>) {
|
||||
if ($_=~/^[^#]/o){
|
||||
push @bup, $_;
|
||||
}
|
||||
}
|
||||
print "POTFILES.ignore found! Ignoring files...\n";
|
||||
@buf2 = (@bup, @buf2);
|
||||
}
|
||||
|
||||
foreach my $file (@buf1){
|
||||
open FILE, "<$file";
|
||||
while (<FILE>) {
|
||||
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;
|
||||
}
|
74
po/update.sh
74
po/update.sh
@ -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;
|
Loading…
Reference in New Issue
Block a user