Skip to content

Commit 6ce8bcd

Browse files
authored
Merge pull request #1642 from UlrichB22/translate_docs
Upd devel/translate docs
2 parents 2be8bc8 + 42ee49c commit 6ce8bcd

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

docs/devel/translate.rst

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,20 @@ A newly created translation needs a few initial preparations:
116116
Note for developers
117117
-------------------
118118

119-
Since we support newstyle gettext there is no need to use the
120-
``format()``-Method in internationalized Strings anymore. An example
121-
will explain this: instead of
122-
``_('Hello %(name)s!') % dict(name='World')`` you can just
123-
write ``_('Hello %(name)s!', name='World')``.
119+
We use the ``format()``-Method in internationalized Strings, e.g.
120+
``_('Hello {name}').format(name='World')``. ``_()`` is an alias for ``gettext()``
124121

125122
If the translatable string contains a variable plural, that means
126-
the string contains an object which you don't know the exact quantity
127-
of, then you will have to use
128-
``ngettext()``. Note that this is not only needed for the decision
123+
the string contains an object whose exact number you don't know,
124+
you will have to use ``N_()``, which is an alias for ``ngettext()``.
125+
Note that this is not only needed for the decision
129126
between one and more objects, because other languages have other
130127
and more difficult plurals than English. The usage is
131-
``ngettext(singular, plural, num, **variables)``. ``**variables``
132-
enables you to use the newstyle form as explained above.
128+
``N_(singular, plural, num).format(**variables)``. ``**variables``
129+
are used to substitute the keys by ``format()`` as explained above.
133130

134-
For example:
135-
``ngettext("%(number)d file removed from %(directory)s", "%(number)d files removed from %(directory)s", num=n, number=n, directory=directory)``
131+
Example:
132+
``N_('{number} file removed from {directory}', '{number} files removed from {directory}', num=n).format(number=n, directory=directory)``
136133

137134
``n`` has to appear twice because the first gives ngettext() information
138135
about the exact number and the second is the variable for the format

0 commit comments

Comments
 (0)