summaryrefslogtreecommitdiffhomepage
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rwxr-xr-xbuild/check-controllers.sh2
-rwxr-xr-xbuild/i18n-add-language.sh37
-rwxr-xr-xbuild/i18n-scan.pl47
-rwxr-xr-xbuild/i18n-sync.sh2
-rw-r--r--build/luadoc/luadoc/config.lua2
5 files changed, 80 insertions, 10 deletions
diff --git a/build/check-controllers.sh b/build/check-controllers.sh
index 573e6f864..47f66eac9 100755
--- a/build/check-controllers.sh
+++ b/build/check-controllers.sh
@@ -14,7 +14,7 @@ find . -type f -name '*.lua' -path '*/controller/*' | while read controller; do
package="${controller##*/controller/}"; package="${package%.lua}"; package="luci.controller.${package//\//.}"
if ! grep -sqE '\bmodule[[:space:]]*\(?[[:space:]]*("|\047|\[=*\[)'"$package" "$controller"; then
- echo "'$controller' does not containt the expected\n\t'module(\"$package\", ...)' line.\n"
+ echo "'$controller' does not contain the expected\n\t'module(\"$package\", ...)' line.\n"
fi
grep -sqE '\b(Form|SimpleForm)[[:space:]]*\(' "$model" && ! grep -sqE '\bMap[[:space:]]*\(' "$model" && is_form=1 || is_form=0
diff --git a/build/i18n-add-language.sh b/build/i18n-add-language.sh
new file mode 100755
index 000000000..24203c233
--- /dev/null
+++ b/build/i18n-add-language.sh
@@ -0,0 +1,37 @@
+#!/usr/bin/env bash
+
+LANG=$1
+
+case "$LANG" in
+ [a-z][a-z]|[a-z][a-z]-[a-z][a-z]) : ;;
+ *)
+ echo "Usage: $0 <ISO_CODE>\n" >&2
+ exit 1
+ ;;
+esac
+
+ADDED=0
+
+for podir in ./*/*/po; do
+ [ -d "$podir/templates" ] || continue
+
+ mkdir "$podir/$LANG"
+ for catalog in $(cd "$podir/templates"; echo *.pot); do
+ if [ -f "$podir/templates/$catalog" -a ! -f "$podir/$LANG/${catalog%.pot}.po" ]; then
+ msginit --no-translator -l "$LANG" -i "$podir/templates/$catalog" -o "$podir/$LANG/${catalog%.pot}.po"
+ git add "$podir/$LANG/${catalog%.pot}.po"
+ ADDED=$((ADDED + 1))
+ fi
+ done
+done
+
+if [ $ADDED -gt 0 ]; then
+ echo ""
+ echo "Added $ADDED new translation catalogs for language '$LANG'."
+ echo "Please also edit 'luci.mk' and add"
+ echo ""
+ echo " LUCI_LANG.$LANG=Native Language Name"
+ echo ""
+ echo "to properly package the translation files."
+ echo ""
+fi
diff --git a/build/i18n-scan.pl b/build/i18n-scan.pl
index 899d90d22..f47fc3553 100755
--- a/build/i18n-scan.pl
+++ b/build/i18n-scan.pl
@@ -3,8 +3,11 @@
use strict;
use warnings;
use Text::Balanced qw(extract_bracketed extract_delimited extract_tagged);
+use POSIX;
-@ARGV >= 1 || die "Usage: $0 <source direcory>\n";
+POSIX::setlocale(POSIX::LC_ALL, "C");
+
+@ARGV >= 1 || die "Usage: $0 <source directory>\n";
my %stringtable;
@@ -33,7 +36,7 @@ sub dec_tpl_str
}
-if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' ')' |" )
+if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' -o -name '*.js' ')' | sort |" )
{
while( defined( my $file = readline F ) )
{
@@ -47,11 +50,21 @@ if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' ')' |" )
my $text = $raw;
+ my $line = 1;
- while( $text =~ s/ ^ .*? (?:translate|translatef|i18n|_) [\n\s]* \( /(/sgx )
+ while( $text =~ s/ ^ (.*?) (?:translate|translatef|i18n|_) ([\n\s]*) \( /(/sgx )
{
+ my ($prefix, $suffix) = ($1, $2);
+
( my $code, $text ) = extract_bracketed($text, q{('")});
+ $line += () = $prefix =~ /\n/g;
+
+ my $position = "$file:$line";
+
+ $line += () = $suffix =~ /\n/g;
+ $line += () = $code =~ /\n/g;
+
$code =~ s/\\\n/ /g;
$code =~ s/^\([\n\s]*//;
$code =~ s/[\n\s]*\)$//;
@@ -88,20 +101,33 @@ if( open F, "find @ARGV -type f '(' -name '*.htm' -o -name '*.lua' ')' |" )
}
$res = dec_lua_str($res);
- $stringtable{$res}++ if $res;
+
+ if ($res) {
+ $stringtable{$res} ||= [ ];
+ push @{$stringtable{$res}}, $position;
+ }
}
$text = $raw;
+ $line = 1;
- while( $text =~ s/ ^ .*? <% -? [:_] /<%/sgx )
+ while( $text =~ s/ ^ (.*?) <% -? [:_] /<%/sgx )
{
+ $line += () = $1 =~ /\n/g;
+
( my $code, $text ) = extract_tagged($text, '<%', '%>');
if( defined $code )
{
+ my $position = "$file:$line";
+
+ $line += () = $code =~ /\n/g;
+
$code = dec_tpl_str(substr $code, 2, length($code) - 4);
- $stringtable{$code}++;
+
+ $stringtable{$code} ||= [];
+ push @{$stringtable{$code}}, $position;
}
}
}
@@ -119,8 +145,15 @@ if( open C, "| msgcat -" )
{
if( length $key )
{
+ my @positions = @{$stringtable{$key}};
+
+ $key =~ s/\\/\\\\/g;
+ $key =~ s/\n/\\n/g;
+ $key =~ s/\t/\\t/g;
$key =~ s/"/\\"/g;
- printf C "msgid \"%s\"\nmsgstr \"\"\n\n", $key;
+
+ printf C "#: %s\nmsgid \"%s\"\nmsgstr \"\"\n\n",
+ join(' ', @positions), $key;
}
}
diff --git a/build/i18n-sync.sh b/build/i18n-sync.sh
index d4f966658..ad8c46c6f 100755
--- a/build/i18n-sync.sh
+++ b/build/i18n-sync.sh
@@ -7,7 +7,7 @@
./build/mkbasepot.sh
-find . -name '*.pot' -and -not -name base.pot -and -not -name rrdtool.pot | \
+find . -name '*.pot' -and -not -name base.pot | \
while read path; do
dir="${path%/po/templates/*}"
echo -n "Updating ${path#./} ... "
diff --git a/build/luadoc/luadoc/config.lua b/build/luadoc/luadoc/config.lua
index 9e4b9de3c..319e1cb03 100644
--- a/build/luadoc/luadoc/config.lua
+++ b/build/luadoc/luadoc/config.lua
@@ -1,6 +1,6 @@
-------------------------------------------------------------------------------
-- LuaDoc configuration file. This file contains the default options for
--- luadoc operation. These options can be overriden by the command line tool
+-- luadoc operation. These options can be overridden by the command line tool
-- @see luadoc.print_help
-- @release $Id: config.lua,v 1.6 2007/04/18 14:28:39 tomas Exp $
-------------------------------------------------------------------------------