Changes to make translation building work better.

This commit is contained in:
Andrew McMillan 2006-11-07 10:37:02 +13:00
parent d5af3a957b
commit f99588f969
2 changed files with 14 additions and 12 deletions

View File

@ -48,17 +48,18 @@ sub extract {
# 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;
$text =~ s/\"/\\\"/sg; # escape double-quotes
$strings{qq{gettext("$text")}}++;
# 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' => '...'))
@ -72,6 +73,7 @@ sub extract {
# 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")}}++;
}

View File

@ -12,7 +12,7 @@ PODIR="po"
LOCALEDIR="locale"
APPLICATION="rscds"
${POTOOLS}/extract.pl htdocs inc > ${PODIR}/strings.raw
${POTOOLS}/extract.pl htdocs inc ../awl/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.po
rm ${PODIR}/messages.tmp