Commit graph

152 commits

Author SHA1 Message Date
Paul Spooren
c4a4e43e2e treewide: replace which with command -v
Fix shellcheck SC2230
> which is non-standard. Use builtin 'command -v' instead.

Once applied to everything concerning OpenWrt we can disable the busybox
feature `which` and save 3.8kB.

Signed-off-by: Paul Spooren <mail@aparcar.org>
2020-08-20 15:54:54 -10:00
Hannu Nyman
da7c3d9202 build/i18n-merge-master: ignore apps deleted in master
Refine the code to ignore apps that have been deleted from master
but still exist in release branches. E.g. luci-app-samba

Previously the unhandled git error from non-existing master
mangled the .po files in the release branch: the 18n header was
removed and all non-ASCII chars were deleted from translation.

Fix this by processing only those files where 'git show' succeeds.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>

(cherry picked from commit e4baee8d25 in openwrt-19.07)
2020-05-15 16:46:23 +03:00
Jo-Philipp Wich
0bc2970640 build: i18n-scan.pl: make ACL descriptions translatable
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-04-17 16:12:03 +02:00
Jo-Philipp Wich
556e14c743 luci-app-statistics: convert plugin definitions to JSON
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-06 12:54:07 +01:00
Jo-Philipp Wich
535d4cf8b9 build: i18n-add-language.sh: more lenient code validation
Allow language codes with underscores and capital letters.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-02-05 14:16:12 +01:00
Jo-Philipp Wich
cab574958c build: add script to merge master translation into branches
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-29 08:40:30 +01:00
Jo-Philipp Wich
9939fc5a26 luci-base: add support for plural translations and contexts in Lua api
- Introduce a new luci.template.parser.ntranslate() function which
   takes a count, a singular and a plural translation string as well
   as an optional context argument and returns the appropriate,
   language specific plural translation.

 - Introduce an optional translation context argument in the existing
   luci.template.parser.translate() function

 - Support translation contexts in LuCI template directives.
   Translation messages are split on the first unescaped pipe
   character and the reamining string after the pipe is treated
   as context.

Examples:

 - `string.format(p.ntranslate(n, "1 apple", "%d apples"), n)` will
   return an appropriate plural translation for the given amount.

 - `translate("Load", "The system load")` will return an appropiate
   translation for `Load`, using `The system load` as disambiguation
   context (a `msgctxt` directive in *.po files).

 - Likewise `<%:Load|The system load%>` will translate the word
   `Load` while using the remainder of the string as context.

 - To use pipes in translations strings literally, they must be
   escaped: `<%:Use the "\|" character%>` will translate the literal
   string `Use the "|" character`.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2020-01-25 23:21:35 +01:00
Jo-Philipp Wich
901a0821f6 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>
2020-01-22 22:02:24 +01:00
Hannu Nyman
460bdfe814 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>
2020-01-08 20:21:23 +01:00
Jo-Philipp Wich
9f9358c3e2 build: i18n-scan.pl: support extracting translations from menu json
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-12-16 18:07:17 +01:00
Jo-Philipp Wich
d5dff8f9a5 treewide: move server side CBI support to luci-compat
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-11-03 20:49:31 +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
e6604d7d84 build: add i18n-add-language.sh helper
This script helps to initialize a new translation language over
the entire source tree.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2019-01-10 10:37:52 +01:00
Hannu Nyman
36b1c60efc luci-app-statistics: remove old deprecated rrdtool po files
Remove old rrdtool.po* files that have been deprecated already
in 2011-2015.

Also remove reference to them from i18n-sync.pl

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-11-11 18:10:46 +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
Hannu Nyman
90e749c63d build/mkbasepot.sh: Fix i18n after luci-mod-admin-full split
Fix i18n sync scripts by including also the three new modules
luci-mod-{network,status,system} in base.pot.

Note: I did not remove luci.mod-admin-full in case it will ever
get some new contents.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2018-09-19 21:50:59 +03:00
Jo-Philipp Wich
6f47c5657f build: add check-controller.sh, a utility to test controller files
The main purpose of the script is to check if the module declaration
matches and if associated cbi resources are properly referenced.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
2018-04-06 12:02:37 +02:00
Hannu Nyman
f8eee09f55 build/zoneinfo2lua.pl: logic for Etc/GMT timezones
Add logic to add Etc/GMT timezones (like GMT+5)
although the zones are not included in zone.tab

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2017-05-08 19:29:43 +03:00
Stefan Weil
cd43e35b9d build/luadoc: Fix typos (found by codespell)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
2016-03-26 10:20:46 +01:00
Jo-Philipp Wich
6c72dec7e5 build/makedocs.sh: handle relative output directories
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-09-02 09:39:24 +02:00
Jo-Philipp Wich
5fd8761583 build: rework i18n-sync.sh to support new structure
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-04-20 10:17:23 +02:00
Hannu Nyman
cdb9de9a9d zoneinfo2lua.pl to generate shorter copyright messages
Change zoneinfo2lua.pl to generate the short copyright messages
that have been there since 7a3493b1f7

Also change the advice on line 3 about directory, where this script
should be run.

Signed-off-by: Hannu Nyman <hannu.nyman@iki.fi>
2015-02-04 19:16:46 +02:00
Jo-Philipp Wich
c669c01cea build: add modified luadoc for use with LuCI sources
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-28 22:28:04 +01:00
Jo-Philipp Wich
b348413fb2 build: remove remainders of old build system
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:52:51 +01:00
Jo-Philipp Wich
eb25d532a8 build: adapt zoneinfo2lua.pl to new structure
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:51:47 +01:00
Jo-Philipp Wich
fe9ef86750 build: adapt i18n-update.pl to new structure
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:46:58 +01:00
Jo-Philipp Wich
85e4256a7a build: adapt mkbasepot.sh to new structure
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:40:09 +01:00
Jo-Philipp Wich
1bb4822dca Rework LuCI build system
* Rename subdirectories to their repective OpenWrt package names
 * Make each LuCI module its own standalone package
 * Deploy a shared luci.mk which is used by each module Makefile

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2015-01-08 16:26:20 +01:00
Jo-Philipp Wich
212d7be533 build: rewrite mkversion.sh to use git metadata (#239)
The current build/mkversion.sh still expected an SVN repository layout,
rewrite it to derive tags and branchnames from git metadata.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-11-01 09:53:02 +01:00
Jo-Philipp Wich
0856030c79 build: generate strictly increasing git revisions (#225)
Instead of simply emitting a "git-$hash" revision, take the commit time into
account to generate strictly increasing revisions to preserve opkg upgrade
capabilities.

The format is "git-YY.DDD.SSSSS-HHHHHHH" with the following defined fields:

  - YY        year number (00..99)
  - DDD       day of year (001..366)
  - SSSSSS    second of day (00000..86399)
  - HHHHHHH   abbreviated git commit hash

An example revision is "git-14.283.50202-bb388f0".

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-10-14 13:51:37 +02:00
Jo-Philipp Wich
91ac51d693 build: preserve original .po header when updating from templates to reduce diff noise
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-06-13 09:40:43 +00:00
Jo-Philipp Wich
d733688ce5 build: adjust mkbasepot.sh after modules/base merge
Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
2014-06-13 09:40:40 +00:00
Jo-Philipp Wich
cf99c53a74 build: add mkrevision.sh helper script which properly infers the revision from either svn, git-svn or git work copies 2013-03-25 11:05:34 +00:00
Jo-Philipp Wich
ffec6bd451 build: remove two obsolete scripts 2012-12-18 14:20:10 +00:00
Daniel Golle
8da6c1a49f properly support git in build/i18n-init.sh 2012-11-20 11:42:35 +00:00
Jo-Philipp Wich
30a0e92e22 build: i18n-sync.sh: also recreate base.pot 2012-07-01 22:58:17 +00:00
Jo-Philipp Wich
0b0df324bf build: fixup header order in i18n-update.pl to minimize diffs to pootle 2012-07-01 22:46:49 +00:00
Jo-Philipp Wich
3944cdaac4 build: add i18n-sync.sh, a script to automatically sync most translations 2012-06-27 18:02:50 +00:00
Jo-Philipp Wich
c60254089d build: escape backslashes in i18n strings 2012-04-22 14:29:00 +00:00
Jo-Philipp Wich
0231c25655 build/i18n-init.sh: add git support
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
2012-04-06 09:44:46 +00:00
Jo-Philipp Wich
ec79d9318d build/i18n-init.sh: allow to use custom pattern for template files
This allows to initialize language files for individual modules.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
2012-04-06 09:44:43 +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
5dd25cf43e build: override sys.user.getpasswd and nixio.fs.access in sdk environment 2012-03-13 23:18:13 +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
fa9c8e72e8 build: mkbasepot.sh: scan protocols/ as well 2011-10-27 00:46:29 +00:00
Jo-Philipp Wich
158f709af3 build: Bail out the build if any lua compilation fails. (Patch from Fon-NG, http://trac.fonosfera.org/fon-ng/changeset/1867) 2011-09-03 17:07:38 +00:00
Jo-Philipp Wich
7d73e79c49 build: add i18n-init.sh, a helper script to initalize missing *.po files 2011-05-21 21:22:47 +00:00