Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • firmware/gluon
  • 0x4A6F/gluon
  • patrick/gluon
3 results
Select Git revision
Loading items
Show changes
Showing
with 1246 additions and 367 deletions
...@@ -10,53 +10,70 @@ General guidelines ...@@ -10,53 +10,70 @@ General guidelines
nice-to-have, but not required. If you don't know a language well, rather leave the translation 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. blank, so it is obvious that there is no proper translation yet.
* Existing expert mode packages should be made translatable as soon as possible. * 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 * The "message IDs" (which are the arguments to the *translate* function) should be the
English texts. English texts.
i18n support in LuCI i18n support in Gluon
-------------------- ---------------------
Internationalization support can be found in the ``luci.i18n`` package. Internationalization support is available in all components (models, view and
Strings are translated using the ``i18n.translate`` and ``i18n.translatef`` functions controllers) of *gluon-web*-based packages. Strings are translated using the *translate*,
(``translate`` for static strings, ``translatef`` for printf-like formatted string). *_translate* and *translatef* functions (*translate* for static strings, *translatef*
for printf-like formatted string; *_translate* works the same as *translate*, but
will return *nil* instead of the original string when no translation is available).
Example from the ``gluon-config-mode-geo-location`` package:: In views, the special tags ``<%:...%>`` can be used to translate the contained string.
local i18n = require "luci.i18n" Example from the *gluon-config-mode-geo-location* package:
o = s:option(cbi.Flag, "_location", i18n.translate("Show node on the map"))
.. code-block:: lua
local share_location = s:option(Flag, "location", translate("Show node on the map"))
Note that translations are *namespaced*: each package will only use its own
translation strings by default. For this purpose, the package name must by
specified in a package's controller. It is possible to access a different
translation package using the *i18n* function from models and view, which is
necessary when strings from the site configuration are used, or packages do not
have their own controller (which is the case for config mode wizard components).
.. code-block:: lua
local site_i18n = i18n 'gluon-site'
local msg = site_i18n._translate('gluon-config-mode:welcome')
Adding translation templates to Gluon packages Adding translation templates to Gluon packages
---------------------------------------------- ----------------------------------------------
The i18n support is based on the standard gettext system. For each translatable package, 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`` a translation template with extension ``.pot`` can be created using the *i18n-scan.pl*
script from the LuCI repository:: script in the ``contrib`` directory:
cd package/gluon-config-mode-geo-location .. code-block:: sh
cd package/gluon-web-mesh-vpn-fastd
mkdir i18n mkdir i18n
cd i18n cd i18n
../../../packages/luci/build/i18n-scan.pl ../files > gluon-config-mode-geo-location.pot ../../../contrib/i18n-scan.pl ../files ../luasrc > gluon-web-mesh-vpn-fastd.pot
The entries in the template can be reordered after the generation if desirable. Lots of standard The same command can be run again to update the template.
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``, In addition, the Makefile must be adjusted. Instead of OpenWrt's default *package.mk*,
the Gluon version ``$(GLUONDIR)/include/package.mk`` must be used. The i18n files must be installed the Gluon version (``../gluon.mk`` for core packages) must be used. The i18n files must be installed
and PKG_CONFIG_DEPENDS must be added:: and PKG_CONFIG_DEPENDS must be added::
... ...
include $(GLUONDIR)/include/package.mk include ../gluon.mk
PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG) PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG)
... ...
define Build/Compile define Build/Compile
$(call GluonBuildI18N,gluon-config-mode-geo-location,i18n) $(call GluonBuildI18N,gluon-web-mesh-vpn-fastd,i18n)
endef endef
define Package/gluon-config-mode-geo-location/install define Package/gluon-web-mesh-vpn-fastd/install
... ...
$(call GluonInstallI18N,gluon-config-mode-geo-location,$(1)) $(call GluonInstallI18N,gluon-web-mesh-vpn-fastd,$(1))
endef endef
... ...
...@@ -64,29 +81,29 @@ and PKG_CONFIG_DEPENDS must be added:: ...@@ -64,29 +81,29 @@ and PKG_CONFIG_DEPENDS must be added::
Adding translations Adding translations
------------------- -------------------
A new translation file for a template can be added using the ``msginit`` command:: A new translation file for a template can be added using the *msginit* command:
.. code-block:: sh
cd package/gluon-config-mode-geo-location/i18n cd package/gluon-web-mesh-vpn-fastd/i18n
msginit -l de msginit -l de
This will create the file ``de.po`` in which the translations can be added. 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:: 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 .. code-block:: sh
msgmerge -U de.po gluon-web-mesh-vpn-fastd.pot
After the merge, the translation file should be checked for "fuzzy matched" entries where 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 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 translated in the *.po* file (or removed from it, so the original English texts are displayed
instead). instead).
Adding support for new languages Adding support for new languages
-------------------------------- --------------------------------
A list of all languages supported by LuCI can be found in the ``packages/luci/luci.mk`` file after A list of all languages supported by *gluon-web* can be found in ``package/gluon.mk``.
Gluon's dependencies have been downloaded using ``make update``. Adding translations for these New languages just need to be added to *GLUON_SUPPORTED_LANGS*, and a human-readable
languages is straightforward using the ``msginit`` command. language name must be defined.
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.
This diff is collapsed.
Views
=====
The template parser reads views from the ``view`` subdirectory of a
gluon-web application (``/lib/gluon/config-mode/view`` for the config mode,
``lib/gluon/status-page/view`` for the status page).
Writing own views should usually be avoided in favour of using :doc:`model`
with their predefined views.
Views are partial HTML pages, with additional template tags that allow
to embed Lua code and translation strings. The following tags are defined:
- ``<%`` ... ``%>`` evaluates the enclosed Lua expression.
- ``<%|`` ... ``%>`` evaluates the enclosed Lua expression and prints its value.
- ``<%=`` ... ``%>`` evaluates the enclosed Lua expression and prints its value
*without escaping HTML entities*. This is useful when the value contains HTML code.
- ``<%+`` ... ``%>`` includes another template.
- ``<%:`` ... ``%>`` translates the enclosed string using the loaded i18n catalog.
- ``<%_`` ... ``%>`` translates the enclosed string *without escaping HTML entities*
in the translation. This only makes sense when the i18n catalog contains HTML code.
- ``<%#`` ... ``%>`` is a comment.
All of these also come in the whitespace-stripping variants ``<%-`` and ``-%>`` that
remove all whitespace before or after the tag.
Complex combinations of HTML and Lua code are possible, for example:
.. code-block:: text
<div>
<% if foo then %>
Content
<% end %>
</div>
Variables and functions
-----------------------
Many call sites define additional variables (for example, model templates can
access the model as *self* and a unique element ID as *id*), but the following
variables and functions should always be available for the embedded Lua code:
- *renderer*: :ref:`web-controller-template-renderer`
- *http*: :ref:`web-controller-http`
- *request*: Table containing the path components of the current page
- *url* (*path*): returns the URL for the given path, which is passed as a table of path components.
- *attr* (*key*, *value*): Returns a string of the form ``key="value"``
(with a leading space character before the key).
*value* is converted to a string (tables are serialized as JSON) and HTML entities
are escaped. Returns an empty string when *value* is *nil* or *false*.
- *include* (*template*): Includes another template.
- *node* (*path*, ...): Returns the controller node for the given page (passed as
one argument per path component).
Use ``node(unpack(request))`` to get the node for the current page.
- *pcdata* (*str*): Escapes HTML entities in the passed string.
- *urlencode* (*str*): Escapes the passed string for use in an URL.
- *translate*, *_translate*, *translatef* and *i18n*: see :doc:`i18n`
This diff is collapsed.
docs/features/configmode.png

112 KiB

This diff is collapsed.
This diff is collapsed.
docs/features/fastd_mode.gif

28.1 KiB

This diff is collapsed.
This diff is collapsed.
docs/features/multidomain_configmode.gif

57.1 KiB

This diff is collapsed.
This diff is collapsed.
docs/features/status-page.png

150 KiB

This diff is collapsed.
TLS support
===========
The generic TLS implementation which is currently used by OpenWRT can be installed or added as dependency through the package ``gluon-tls``.
This removes the need for community packages to depend on a specific TLS implementation (like mbedtls, OpenSSL or WolfSSL).
This package is an alias for the current TLS implementation used.
To allow for easy usage of communicating through HTTPS from the node, typical Certificate Authorities (CAs) are included through the package ``ca-bundle`` .
* Starting with OpenWRT 23.05, mbedtls is the default TLS layer - this is reflected in Gluon :ref:`v2023.2 <releases-v2023.2-minor-changes>`. HTTPS is used by default to communicate with OpenWRT opkg servers.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.