93 lines
3.7 KiB
ReStructuredText
93 lines
3.7 KiB
ReStructuredText
Internationalization support
|
|
============================
|
|
|
|
General guidelines
|
|
------------------
|
|
|
|
* All config mode packages must be fully translatable, with complete English and German texts.
|
|
* 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.
|
|
* Existing expert mode packages should be made translatable as soon as possible.
|
|
* The "message IDs" (which are the arguments to the ``translate`` function) should be the
|
|
English texts.
|
|
|
|
i18n support in LuCI
|
|
--------------------
|
|
|
|
Internationalization support can be found in the ``luci.i18n`` package.
|
|
Strings are translated using the ``i18n.translate`` and ``i18n.translatef`` functions
|
|
(``translate`` for static strings, ``translatef`` for printf-like formatted string).
|
|
|
|
Example from the ``gluon-config-mode-geo-location`` package::
|
|
|
|
local i18n = require "luci.i18n"
|
|
o = s:option(cbi.Flag, "_location", i18n.translate("Show node on the map"))
|
|
|
|
Adding translation templates to Gluon packages
|
|
----------------------------------------------
|
|
|
|
The i18n support is based on the standard gettext system. For each translatable package,
|
|
a translation template with extension ``.pot`` can be created using the ``i18n-scan.pl``
|
|
script from the LuCI repository::
|
|
|
|
cd package/gluon-config-mode-geo-location
|
|
mkdir i18n
|
|
cd i18n
|
|
../../../packages/luci/build/i18n-scan.pl ../files > gluon-config-mode-geo-location.pot
|
|
|
|
The entries in the template can be reordered after the generation if desirable. Lots of standard
|
|
translations like "Cancel" are already available in the LuCI base translation file (see
|
|
``packages/luci/po/templates/base.pot``) and can be removed from the template.
|
|
|
|
In addition, some additions to the Makefile must be made. Instead of OpenWrt's default ``package.mk``,
|
|
the Gluon version ``$(GLUONDIR)/include/package.mk`` must be used. The i18n files must be installed
|
|
and PKG_CONFIG_DEPENDS must be added::
|
|
|
|
...
|
|
include $(GLUONDIR)/include/package.mk
|
|
|
|
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
|
|
...
|
|
define Build/Compile
|
|
$(call GluonBuildI18N,gluon-config-mode-geo-location,i18n)
|
|
endef
|
|
|
|
define Package/gluon-config-mode-geo-location/install
|
|
...
|
|
$(call GluonInstallI18N,gluon-config-mode-geo-location,$(1))
|
|
endef
|
|
...
|
|
|
|
|
|
Adding translations
|
|
-------------------
|
|
|
|
A new translation file for a template can be added using the ``msginit`` command::
|
|
|
|
cd package/gluon-config-mode-geo-location/i18n
|
|
msginit -l de
|
|
|
|
This will create the file ``de.po`` in which the translations can be added.
|
|
|
|
The translation file can be updated to a new template version using the ``msgmerge`` command::
|
|
|
|
msgmerge -U de.po gluon-config-mode-geo-location.pot
|
|
|
|
After the merge, the translation file should be checked for "fuzzy matched" entries where
|
|
the original English texts have changed. All entries from the translation file should be
|
|
translated in the ``.po`` file (or removed from it, so the original English texts are displayed
|
|
instead).
|
|
|
|
Adding support for new languages
|
|
--------------------------------
|
|
|
|
A list of all languages supported by LuCI can be found in the ``packages/luci/luci.mk`` file after
|
|
Gluon's dependencies have been downloaded using ``make update``. Adding translations for these
|
|
languages is straightforward using the ``msginit`` command.
|
|
|
|
For other languages, support must be added to LuCI first, which constitutes completely translating
|
|
the ``base.pot``. Please contact the upstream LuCI maintainers at https://github.com/openwrt/luci/
|
|
if you'd like to do this.
|