mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-01-27 00:33:34 +00:00
Move from extract.pl to standard xgettext
So far we have used extract.pl which originated in Horde to generate the PO files. This process took a long time to run. But xgettext is able to handle PHP by itself. In the source translate() and i18n() are used instead of _() therefore we have to pass a keyword parameter. From now on Translators: is the keyword to provide content to the translators on Transifex. Conflicts: scripts/po/extract.pl
This commit is contained in:
parent
a9231717c9
commit
5debe92237
2
Makefile
2
Makefile
@ -11,7 +11,7 @@ built-docs: docs/api/phpdoc.ini htdocs/*.php inc/*.php
|
||||
phpdoc -c docs/api/phpdoc.ini || echo "NOTICE: Failed to build optional API docs"
|
||||
touch built-docs
|
||||
|
||||
built-po: htdocs/always.php scripts/po/rebuild-translations.sh scripts/po/extract.pl po/*.po
|
||||
built-po: htdocs/always.php scripts/po/rebuild-translations.sh po/*.po
|
||||
scripts/po/rebuild-translations.sh
|
||||
touch built-po
|
||||
|
||||
|
||||
@ -15,14 +15,14 @@ if ( isset($_SERVER['HTTP_REFERER']) ) {
|
||||
$wiki_help = 'w/Help/'.$wiki_help;
|
||||
}
|
||||
|
||||
$content = translate('<h1>Help</h1>
|
||||
$content = sprintf(translate('<h1>Help</h1>
|
||||
<p>For initial help you should visit the <a href="http://www.davical.org/" target="_blank">DAViCal Home Page</a> or take
|
||||
a look at the <a href="http://wiki.davical.org/'.$wiki_help.'" target="_blank">DAViCal Wiki</a>.</p>
|
||||
a look at the <a href="http://wiki.davical.org/%s" target="_blank">DAViCal Wiki</a>.</p>
|
||||
<p>If you can\'t find the answers there, visit us on <a href="http://wikipedia.org/wiki/Internet_Relay_Chat" target="_blank">IRC</a> in
|
||||
the <b>#davical</b> channel on <a href="http://www.oftc.net/" target="_blank">irc.oftc.net</a>,
|
||||
or send a question to the <a href="http://lists.sourceforge.net/mailman/listinfo/davical-general" target="_blank">DAViCal Users mailing list</a>.</p>
|
||||
<p>The <a href="http://sourceforge.net/mailarchive/forum.php?forum_id=8348" title="DAViCal Users Mailing List" target="_blank">mailing list
|
||||
archives can be helpful too.</p>');
|
||||
archives can be helpful too.</p>'), $wiki_help);
|
||||
|
||||
echo $content;
|
||||
|
||||
|
||||
@ -3,32 +3,29 @@
|
||||
* This file is not included anywhere. It exists as a way of ensuring some
|
||||
* strings, which may come from the database, or from other places, are
|
||||
* present in the translation files.
|
||||
*
|
||||
* It is also used to add extra entries to the translations which document
|
||||
* the sense of a word or phrase to assist with translations.
|
||||
*/
|
||||
|
||||
// Groups, from the database
|
||||
i18n("Admin <!-- in the sense of 'systems admin' -->");
|
||||
# Translators: in the sense of 'systems admin'
|
||||
i18n("Admin");
|
||||
|
||||
i18n("Group <!-- in the sense of a group of people -->");
|
||||
# Translators: in the sense of a group of people
|
||||
i18n("Group");
|
||||
|
||||
i18n("Public <!-- in the sense of being available to all users -->");
|
||||
# Translators: in the sense of being available to all users
|
||||
i18n("Public");
|
||||
|
||||
i18n("Resource <!-- a thing which might be booked: a room, a carpark, a projector... -->");
|
||||
# Translators a thing which might be booked: a room, a carpark, a projector...
|
||||
i18n("Resource");
|
||||
|
||||
i18n("No. <!-- short for 'Number' -->");
|
||||
# Translators: short for 'Number'
|
||||
i18n("No.");
|
||||
|
||||
i18n("No <!-- not 'Yes' -->");
|
||||
# Translators: not 'Yes'
|
||||
i18n("No");
|
||||
i18n("Yes");
|
||||
|
||||
i18n("Id <!-- short for 'Identifier' -->");
|
||||
# Translators: short for 'Identifier'
|
||||
i18n("Id");
|
||||
|
||||
i18n('View this user record');
|
||||
@ -36,7 +33,8 @@ i18n('Edit this user record');
|
||||
i18n('You are viewing');
|
||||
i18n('You are editing');
|
||||
|
||||
i18n("forget me not <!-- this is a colloquial phrase in english (the name of a flower) and is an option allowing people to log in automatically in future -->");
|
||||
# Translators: this is a colloquial phrase in english (the name of a flower) and is an option allowing people to log in automatically in future
|
||||
i18n("forget me not");
|
||||
|
||||
// Date format types
|
||||
i18n('European');
|
||||
|
||||
52
po/pofilelist.txt
Normal file
52
po/pofilelist.txt
Normal file
@ -0,0 +1,52 @@
|
||||
htdocs/always.php
|
||||
htdocs/caldav.php
|
||||
htdocs/feed.php
|
||||
htdocs/freebusy.php
|
||||
htdocs/help.php
|
||||
htdocs/public.php
|
||||
htdocs/setup.php
|
||||
htdocs/tools.php
|
||||
htdocs/upgrade.php
|
||||
htdocs/well-known.php
|
||||
inc/auth-functions.php
|
||||
inc/caldav-BIND.php
|
||||
inc/caldav-DELETE.php
|
||||
inc/caldav-GET.php
|
||||
inc/caldav-MKCOL.php
|
||||
inc/caldav-MOVE.php
|
||||
inc/caldav-OPTIONS.php
|
||||
inc/caldav-PROPFIND.php
|
||||
inc/caldav-PROPPATCH.php
|
||||
inc/caldav-PUT-default.php
|
||||
inc/caldav-PUT-functions.php
|
||||
inc/caldav-PUT.php
|
||||
inc/caldav-PUT-vcard.php
|
||||
inc/caldav-REPORT-calquery.php
|
||||
inc/caldav-REPORT-cardquery.php
|
||||
inc/caldav-REPORT.php
|
||||
inc/caldav-REPORT-sync-collection.php
|
||||
inc/CalDAVRequest.php
|
||||
inc/DAViCalSession.php
|
||||
inc/DAVResource.php
|
||||
inc/drivers_imap_pam.php
|
||||
inc/drivers_ldap.php
|
||||
inc/drivers_pwauth_pam.php
|
||||
inc/drivers_squid_pam.php
|
||||
inc/interactive-page.php
|
||||
inc/iSchedule.php
|
||||
inc/other_translated_strings.php
|
||||
inc/page-header.php
|
||||
inc/Principal.php
|
||||
inc/ui/collection-edit.php
|
||||
inc/ui/principal-browse.php
|
||||
inc/ui/principal-edit.php
|
||||
inc/WritableCollection.php
|
||||
|
||||
../awl/inc/classBrowser.php
|
||||
../awl/inc/classEditor.php
|
||||
../awl/inc/DataEntry.php
|
||||
../awl/inc/iCalendar.php
|
||||
../awl/inc/PgQuery.php
|
||||
../awl/inc/Session.php
|
||||
../awl/inc/User.php
|
||||
|
||||
@ -1,144 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
#
|
||||
# Perl script to extract strings from all the files and print
|
||||
# to stdout for use with xgettext.
|
||||
#
|
||||
# This script is based on the one provided with the Horde project
|
||||
# http://www.horde.org/. As such, it inherits the license from the
|
||||
# original version. You can find that license here:
|
||||
#
|
||||
# http://cvs.horde.org/co.php/horde/COPYING?r=2.1
|
||||
#
|
||||
# I'm not exactly sure what the license restrictions are in this case,
|
||||
# but I want to give full credit to the original authors, including
|
||||
# the Gallery project which the script passed through on the way.
|
||||
#
|
||||
# Copyright 2000-2002 Joris Braakman <jbraakman@yahoo.com>
|
||||
# Copyright 2001-2002 Chuck Hagenbuch <chuck@horde.org>
|
||||
# Copyright 2001-2002 Jan Schneider <jan@horde.org>
|
||||
# Copyright 2002-2003 Bharat Mediratta <bharat@menalto.com>
|
||||
#
|
||||
#
|
||||
use FileHandle;
|
||||
use File::Basename;
|
||||
use File::Find;
|
||||
use IPC::Open2;
|
||||
use strict;
|
||||
|
||||
my %strings;
|
||||
|
||||
my $exts = '(php|pl)';
|
||||
|
||||
foreach my $moduleDir (@ARGV) {
|
||||
find(\&extract, $moduleDir);
|
||||
}
|
||||
|
||||
print join("\n" => sort keys %strings), "\n";
|
||||
|
||||
sub extract {
|
||||
my $file = $File::Find::name;
|
||||
my $dir = $File::Find::dir;
|
||||
my $fd = new FileHandle;
|
||||
|
||||
if ($file =~ /\.$exts$/) {
|
||||
open($fd, basename($file));
|
||||
my $data = join('' => <$fd>);
|
||||
|
||||
# grab phrases for translate( or i18n( calls; capture string parameter enclosed
|
||||
# in single or double quotes including concatenated strings like 'one' . "two"
|
||||
while ($data =~
|
||||
/(translate|i18n)\(\s*(((\s*\.\s*)?('((\\')?[^']*)*[^\\]'|"((\\")?[^"]*)*[^\\]"))+)\s*\)/sg) {
|
||||
# Call out to php to parse string..
|
||||
my ($in, $out);
|
||||
open2($in, $out, 'php -q');
|
||||
print $out '<?php print ';
|
||||
print $out $2;
|
||||
print $out ' ?>';
|
||||
close $out;
|
||||
my $text = join('', <$in>);
|
||||
close $in;
|
||||
next if ( $text eq "" );
|
||||
$text =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
$strings{qq{gettext("$text")}}++;
|
||||
}
|
||||
|
||||
# grab phrases of this format: translate(array('one' => '...', 'many' => '...'))
|
||||
while ($data =~ /translate\(.*?array\('one'\s*=>\s*'(.*?)'.*?'many'\s*=>\s*'(.*?)'.*?\).*?\)/sg) {
|
||||
my ($one, $many) = ($1, $2);
|
||||
$one =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
$many =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
$strings{qq{ngettext("$one", "$many")}}++;
|
||||
}
|
||||
|
||||
# grab phrases of this format: translate(array('text' => '...', ...))
|
||||
while ($data =~ /translate\(\s*array\('text'\s*=>\s+'(.*?[^\\])'/sg) {
|
||||
my $text = $1;
|
||||
next if ( $text eq "" );
|
||||
$text =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
$strings{qq{gettext("$text")}}++;
|
||||
}
|
||||
|
||||
# grab phrases of this format {g->text ..... }
|
||||
while ($data =~ /(\{\s*g->text\s+.*?[^\\]\})/sg) {
|
||||
my $string = $1;
|
||||
my $text;
|
||||
my $one;
|
||||
my $many;
|
||||
|
||||
# Ignore translations of the form:
|
||||
# text=$foo
|
||||
# as we expect those to be variables containing values that
|
||||
# have been marked elsewhere with the i18n() function
|
||||
if ($string =~ /text=\$/) {
|
||||
next;
|
||||
}
|
||||
|
||||
# text=.....
|
||||
if ($string =~ /text="(.*?[^\\])"/s) {
|
||||
$text = $1;
|
||||
}
|
||||
elsif ($string =~ /text='(.*?)'/s) {
|
||||
$text = $1;
|
||||
$text =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
}
|
||||
|
||||
# one = .....
|
||||
if ($string =~ /\s+one="(.*?[^\\])"/s) {
|
||||
$one = $1;
|
||||
}
|
||||
elsif ($string =~ /\s+one='(.*?)'/s) {
|
||||
$one = $1;
|
||||
$one =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
}
|
||||
|
||||
# many = .....
|
||||
if ($string =~ /\s+many="(.*?[^\\])"/s) {
|
||||
$many = $1;
|
||||
}
|
||||
elsif ($string =~ /\s+many='(.*?)'/s) {
|
||||
$many = $1;
|
||||
$many =~ s/\"/\\\"/sg; # escape double-quotes
|
||||
}
|
||||
|
||||
# pick gettext() or ngettext()
|
||||
if ($text) {
|
||||
$string = qq{gettext("$text")};
|
||||
}
|
||||
elsif ($one and $many) {
|
||||
$string = qq{ngettext("$one", "$many")};
|
||||
}
|
||||
else {
|
||||
# parse error
|
||||
$text =~ s/\n/\n>/sg;
|
||||
print STDERR "extract.pl parse error: $file:\n";
|
||||
print STDERR "> $string\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
$string =~ s/\\\}/\}/sg; # unescape right-curly-braces
|
||||
$strings{qq{$string}}++;
|
||||
}
|
||||
|
||||
close($fd);
|
||||
}
|
||||
}
|
||||
@ -7,7 +7,6 @@
|
||||
|
||||
[ -n "${DEBUG}" ] && set -o xtrace
|
||||
|
||||
POTOOLS="scripts/po"
|
||||
PODIR="po"
|
||||
LOCALEDIR="locale"
|
||||
APPLICATION="davical"
|
||||
@ -21,10 +20,10 @@ if [ ! -d "${AWL_LOCATION}" ]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
${POTOOLS}/extract.pl htdocs inc ${AWL_LOCATION}/inc > ${PODIR}/strings.raw
|
||||
xgettext --keyword=_ -C --no-location --output=${PODIR}/messages.tmp ${PODIR}/strings.raw
|
||||
sed -e 's/CHARSET/UTF-8/' <${PODIR}/messages.tmp >${PODIR}/messages.pot
|
||||
rm ${PODIR}/messages.tmp
|
||||
sed "s:../awl:${AWL_LOCATION}:" ${PODIR}/pofilelist.txt > ${PODIR}/pofilelist.tmp
|
||||
xgettext --no-location --add-comments=Translators --keyword=translate --keyword=i18n --output=${PODIR}/messages.tmp -s -f ${PODIR}/pofilelist.tmp
|
||||
sed 's.^"Content-Type: text/plain; charset=CHARSET\\n"."Content-Type: text/plain; charset=UTF-8\\n".' ${PODIR}/messages.tmp > ${PODIR}/messages.pot
|
||||
rm ${PODIR}/messages.tmp ${PODIR}/pofilelist.tmp
|
||||
|
||||
|
||||
for LOCALE in `grep VALUES dba/supported_locales.sql | cut -f2 -d"'" | cut -f1 -d'_'` ; do
|
||||
@ -32,7 +31,7 @@ for LOCALE in `grep VALUES dba/supported_locales.sql | cut -f2 -d"'" | cut -f1 -
|
||||
if [ ! -f ${PODIR}/${LOCALE}.po ] ; then
|
||||
cp ${PODIR}/messages.pot ${PODIR}/${LOCALE}.po
|
||||
fi
|
||||
msgmerge --quiet --width 105 --update ${PODIR}/${LOCALE}.po ${PODIR}/messages.pot
|
||||
msgmerge --no-fuzzy-matching --quiet --width 105 --update ${PODIR}/${LOCALE}.po ${PODIR}/messages.pot
|
||||
done
|
||||
|
||||
for LOCALE in `grep VALUES dba/supported_locales.sql | cut -f2 -d"'" | cut -f1 -d'_'` ; do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user