Skip to content

Commit

Permalink
core: Consolidate translation files (#1459)
Browse files Browse the repository at this point in the history
* For core modules, consolidate their translation template into
  priv/translations/template/zotonic.pot, using msgcat.
* For core modules, consolidate their translations into
  priv/translations/(lang).po.
* Remove translation files from their old location inside the modules.
* Remove duplicate translations.
* Trim translation labels from templates.
* Extract translations labels as binaries to fix UTF-encoded labels from
  being skipped.
* Update Docker containers to include gettext package, which is
  required for msgmerge and msgcat.
* Update documentation.
  • Loading branch information
ddeboer authored and mworrell committed Oct 4, 2016
1 parent 946111a commit a85aa5d
Show file tree
Hide file tree
Showing 216 changed files with 70,338 additions and 52,597 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ deps/
/priv/mnesia/
/priv/sites/default/files/
/priv/modules/
/priv/translations/template/
/priv/translations/zotonic.pot

/modules/*/translations/template/*.pot

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN sed -f docker/erlang.config.sed priv/erlang.config.in > /etc/zotonic/erlang.
# Note: dumb-init and gosu are pulled from edge; remove that when upgrading to an alpine release that
# includes those packages.
RUN apk add --virtual build-deps --no-cache ca-certificates wget curl make gcc musl-dev g++ bsd-compat-headers git \
&& apk add --no-cache bash imagemagick \
&& apk add --no-cache bash gettext imagemagick \
&& apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ dumb-init \
erlang erlang-inets erlang-compiler erlang-crypto erlang-mnesia erlang-ssl erlang-stdlib erlang-public-key erlang-tools erlang-dev erlang-asn1 erlang-syntax-tools erlang-eunit erlang-parsetools erlang-snmp erlang-sasl erlang-xmerl erlang-erl-interface \
&& apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/testing/ gosu \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ WORKDIR /opt/zotonic

RUN sed -f docker/erlang.config.sed priv/erlang.config.in > /etc/zotonic/erlang.config

RUN apk add --no-cache ca-certificates bash curl make gcc musl-dev g++ bsd-compat-headers git imagemagick inotify-tools wget \
RUN apk add --no-cache ca-certificates bash curl make gcc musl-dev g++ bsd-compat-headers gettext git imagemagick inotify-tools wget \
&& apk add --no-cache --repository http://dl-3.alpinelinux.org/alpine/edge/community/ \
erlang erlang-inets erlang-compiler erlang-crypto erlang-mnesia erlang-ssl erlang-stdlib erlang-public-key erlang-tools erlang-dev erlang-asn1 erlang-syntax-tools erlang-eunit erlang-parsetools erlang-snmp erlang-sasl erlang-xmerl erlang-erl-interface

Expand Down
34 changes: 24 additions & 10 deletions doc/developer-guide/translation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,22 @@ Generation of translations

The fixed texts in a Zotonic website are translated using the `GNU
gettext <http://www.gnu.org/software/gettext/>`_ ``.po`` file format and
its related tools.
its related tools. If you’re not using our :ref:`guide-docker` images, you may
have to install gettext first:

In Zotonic, static translations are organized in each Zotonic
module. It is the module’s responsibility to provide translations for
all the texts that it uses in its templates. All files related to
static translations live inside the ``translations/`` subdirectory of
a module (remember: a Zotonic site is just a module!).
.. code-block:: shell
In the ``translations/`` directory of the modules you can find the ``.po``
files containing the translations. They are marked with the their language code. (Optionally you can name your file like:
$ sudo apt-get install gettext
In Zotonic, translations files are placed in two locations:

- for the core modules, the translation files are consolidated in
:file:`priv/translations/`;
- third-party modules and sites, including your own, have their translation
files in a :file:`translations/` subdirectory in the module itself.

In the translations directory you can find the ``.po`` files containing the
translations. They are marked with the their language code. (Optionally you can name your file like:
nl.foobar.po as Zotonic will only look at the part till the first '.'
for the language code)::

Expand All @@ -102,15 +108,23 @@ for the language code)::
This shows that module ``mod_foo`` has been translated into
Dutch (`nl`), Turkish (`tr`) and Chinese traditional script (`zh-hant`).

The template for translation strings is located in a ``.pot`` file, in ``mod_foo/translations/template/mod_foo.pot``. This pot file is regenerated when you click on the ‘Generate .pot files’ button on the Translation page in the admin. Alternatively,
The ``.po`` translation files are based on translation templates (``.pot``
files). The templates are located in :file:`translations/templates`:

- :file:`priv/translations/template/zotonic.pot` for the core modules;
- :file:`mod_foo/translations/template/mod_foo.pot` for custom modules.

This ``.pot`` file is regenerated when you click on the ‘Generate .pot files’
button on the :ref:`Translation page <mod_translation>` in the admin.
Alternatively,
from your Zotonic shell:

.. code-block:: erlang
mod_translation:generate(Context).
Zotonic will parse all your templates and Erlang modules for translatable
strings. These strings are then added to the .pot file.
strings. These strings are then added to the ``.pot`` files.

Creating a new translation for a module
.......................................
Expand Down
2 changes: 2 additions & 0 deletions doc/ref/installation/requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ installed:
5. **git** Zotonic comes with a few subprojects which are pulled from
the web with the ``git`` command.

6. **gettext** For translation support.

If you meet these requirements, head straight on to :ref:`guide-installation`,
otherwise, read on below for the specifics on these.

Expand Down
114 changes: 0 additions & 114 deletions modules/mod_acl_user_groups/translations/en.po

This file was deleted.

0 comments on commit a85aa5d

Please sign in to comment.