2015-04-25 17:22:15 +00:00
|
|
|
Internationalization support
|
|
|
|
============================
|
|
|
|
|
|
|
|
General guidelines
|
|
|
|
------------------
|
|
|
|
|
|
|
|
* All config mode packages must be fully translatable, with complete English and German texts.
|
2016-08-30 16:32:41 +00:00
|
|
|
* All new expert mode packages must be fully translatable. English texts are required.
|
|
|
|
* German translations are recommended. Other supported languages, especially French, are
|
|
|
|
nice-to-have, but not required. If you don't know a language well, rather leave the translation
|
|
|
|
blank, so it is obvious that there is no proper translation yet.
|
2015-04-25 17:22:15 +00:00
|
|
|
* Existing expert mode packages should be made translatable as soon as possible.
|
2017-02-08 21:19:24 +00:00
|
|
|
* The "message IDs" (which are the arguments to the *translate* function) should be the
|
2015-04-25 17:22:15 +00:00
|
|
|
English texts.
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
i18n support in Gluon
|
|
|
|
---------------------
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
Internationalization support is available in all components (models, view and
|
|
|
|
contrllers) of *gluon-web*-based packages. Strings are translated using the *translate*
|
|
|
|
and *translatef* functions (*translate* for static strings, *translatef*
|
|
|
|
for printf-like formatted string); in views, the special tags ``<%:...%>`` can
|
|
|
|
be used to translate the contained string.
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
Example from the *gluon-config-mode-geo-location* package:
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
.. code-block:: lua
|
|
|
|
|
|
|
|
local share_location = s:option(Flag, "location", translate("Show node on the map"))
|
2015-04-25 17:22:15 +00:00
|
|
|
|
|
|
|
Adding translation templates to Gluon packages
|
|
|
|
----------------------------------------------
|
|
|
|
|
|
|
|
The i18n support is based on the standard gettext system. For each translatable package,
|
2017-02-08 21:19:24 +00:00
|
|
|
a translation template with extension ``.pot`` can be created using the *i18n-scan.pl*
|
|
|
|
script in the ``contrib`` directory:
|
|
|
|
|
|
|
|
.. code-block:: sh
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
cd package/gluon-web-mesh-vpn-fastd
|
2015-04-25 17:22:15 +00:00
|
|
|
mkdir i18n
|
|
|
|
cd i18n
|
2017-02-08 21:19:24 +00:00
|
|
|
../../../contrib/i18n-scan.pl ../files ../luasrc > gluon-web-mesh-vpn-fastd.pot
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
The same command can be run again to update the template.
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
In addition, some additions to the Makefile must be made. Instead of LEDE's default *package.mk*,
|
|
|
|
the Gluon version (``../gluon.mk`` for core packages) must be used. The i18n files must be installed
|
2015-04-25 17:36:21 +00:00
|
|
|
and PKG_CONFIG_DEPENDS must be added::
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2015-04-25 17:36:21 +00:00
|
|
|
...
|
2017-02-08 21:19:24 +00:00
|
|
|
include ../gluon.mk
|
2015-04-25 17:36:21 +00:00
|
|
|
|
|
|
|
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
|
|
|
|
...
|
2015-04-25 17:22:15 +00:00
|
|
|
define Build/Compile
|
2017-02-08 21:19:24 +00:00
|
|
|
$(call GluonBuildI18N,gluon-web-mesh-vpn-fastd,i18n)
|
2015-04-25 17:22:15 +00:00
|
|
|
endef
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
define Package/gluon-web-mesh-vpn-fastd/install
|
2015-04-25 17:22:15 +00:00
|
|
|
...
|
2017-02-08 21:19:24 +00:00
|
|
|
$(call GluonInstallI18N,gluon-web-mesh-vpn-fastd,$(1))
|
2015-04-25 17:22:15 +00:00
|
|
|
endef
|
2015-04-25 17:36:21 +00:00
|
|
|
...
|
2015-04-25 17:22:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
Adding translations
|
|
|
|
-------------------
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
A new translation file for a template can be added using the *msginit* command:
|
|
|
|
|
|
|
|
.. code-block:: sh
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
cd package/gluon-web-mesh-vpn-fastd/i18n
|
2015-04-25 17:22:15 +00:00
|
|
|
msginit -l de
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
This will create the file *de.po* in which the translations can be added.
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
The translation file can be updated to a new template version using the *msgmerge* command:
|
2015-04-25 17:22:15 +00:00
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
.. code-block:: sh
|
|
|
|
|
|
|
|
msgmerge -U de.po gluon-web-mesh-vpn-fastd.pot
|
2015-04-25 17:22:15 +00:00
|
|
|
|
|
|
|
After the merge, the translation file should be checked for "fuzzy matched" entries where
|
2016-08-30 16:32:41 +00:00
|
|
|
the original English texts have changed. All entries from the translation file should be
|
2017-02-08 21:19:24 +00:00
|
|
|
translated in the *.po* file (or removed from it, so the original English texts are displayed
|
2015-04-25 17:22:15 +00:00
|
|
|
instead).
|
|
|
|
|
|
|
|
Adding support for new languages
|
|
|
|
--------------------------------
|
|
|
|
|
2017-02-08 21:19:24 +00:00
|
|
|
A list of all languages supported by *gluon-web* can be found in ``package/gluon.mk``.
|
|
|
|
New languages just need to be added to *GLUON_SUPPORTED_LANGS*, after a human-readable
|
|
|
|
language name has been defined in the same file.
|