Commit graph

19 commits

Author SHA1 Message Date
Jo-Philipp Wich
529d6b7268 build: i18n-scan.pl: use xgettext to extract message strings
Using xgettext has a few benefits compared to the previous perl extraction
approach. The xgettext utility is able to properly distinguish commented
from uncommented code and it is able handle concatenated constant
expressions such as `_("Some " + "string")`.

A further benefit is the ability to extract translations with disambiguation
contexts and plural translation calls.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 901a0821f6)
2020-01-29 08:33:37 +01:00
Jo-Philipp Wich
e578ff9b1c build: i18n-scan.pl: support extracting translations from menu json
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 9f9358c3e2)
2020-01-29 08:33:34 +01:00
Hannu Nyman
de34495d28 build: sort location annotation table in i18n sync process
The scanning routine has caused unnecessary changes to the .po files
if a string has been found in multiple files and those files have been
found in different order than the previous time.

Sort the location annotations to avoid unnecessary changes to the .po files.
(sort is alphabetic, so the line numbers are also sorted alphabetically)

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
[apply a Schwartzian transform to sort locations by path, then line number]
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
(cherry picked from commit 460bdfe814)
2020-01-08 20:23:24 +01:00
Jo-Philipp Wich
4bbc033a96 build: i18n-scan.pl: properly handle bracket-quoted strings
Fixes: #2738
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-05-31 20:11:56 +02:00
Jo-Philipp Wich
4623a58394 build: i18n-scan.pl: *.js support, location annotations
Extend i18n-scan.pl to scan JavaScript files for translation strings as
well and annotate produced *.po template files with source code location
markers.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-11-05 11:01:45 +01:00
yangfl
401382a459 treewide: Fix typos in comments
Signed-off-by: David Yang <mmyangfl@gmail.com>
2018-10-10 15:00:07 +08:00
Jo-Philipp Wich
c60254089d build: escape backslashes in i18n strings 2012-04-22 14:29:00 +00:00
Jo-Philipp Wich
3501cbea52 build: rework checks in i18n-scan.pl 2012-04-03 00:35:54 +00:00
Jo-Philipp Wich
c024eca0fc build: rework i18n-scan.pl defined checks 2012-04-02 23:57:11 +00:00
Jo-Philipp Wich
14a9306e7d build/i18n-scan.pl: avoid a possible endless loop
Issuing './build/i18n-scan.pl libs/core/' leads to this
endless loop with some perl implementations:

<...>
Use of uninitialized value in concatenation (.) or string at../build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
Use of uninitialized value in concatenation (.) or string at ./build/i18n-scan.pl line 69.
substr outside of string at ./build/i18n-scan.pl line 69.
<...>

Experienced with this perl version:
"This is perl, v5.8.8 built for i386-linux"

Fix it by undefining the 'sub' variable if it is an
empty string.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
2012-04-02 22:50:40 +00:00
Jo-Philipp Wich
5e86b77294 build: i18n-scan.pl: cope with strings that contain escaped newlines, spotted in luci-pbx 2011-11-05 18:35:54 +00:00
Jo-Philipp Wich
4ab2d1017e build: fix some errors in i18n-scan.pl, support bracketed Lua string notation 2011-01-14 23:23:37 +00:00
Jo-Philipp Wich
939218ae82 build: properly handle i18n tags with whitespace strip tokens in i18n-scan.pl 2011-01-14 22:51:21 +00:00
Manuel Munz
80b5a4b6f8 build/: Replace -or with -o #133 2010-12-11 17:14:13 +00:00
Jo-Philipp Wich
e3ac0fd78d build: fix corner case when extracting i18n tokens from templates 2009-11-01 01:05:28 +00:00
Jo-Philipp Wich
4ad686d732 build: allow multiple search directories in i18n-scan.pl 2009-11-01 01:01:47 +00:00
Jo-Philipp Wich
58b3b2156f build: update i18n-scan.pl, now reliably finds template and Lua i18n tokens 2009-11-01 00:48:15 +00:00
Jo-Philipp Wich
7df655af2a build: remove debugging code from i18n-scan.pl 2009-05-17 20:00:02 +00:00
Jo-Philipp Wich
5193631c04 build: add script to extract i18n tags from sources and generate *.po snippets 2009-05-17 19:39:32 +00:00