From Fedora Project Wiki

(added alternatve part)
(Fix formating.)
Line 3: Line 3:
{{Anchor|parameters}}
{{Anchor|parameters}}
== Controlling parameters order ==
== Controlling parameters order ==
When translating, sometime the result of particular translated string contains different parameters order. But it usually is not allowed. There is the workaround to change the order in translation, and it can be found at 'info gettext'.
When translating, sometimes the translation of a particular string requires different parameter order. But it is usually not allowed to change them in the translated string. There is the workaround to change the order in translation, and it can be found with `info gettext` command.


For example in German, This won't work:
For example; in German, this won't work:


<code>msgid "String `%s' has %d characters\n"<br>
`msgid "String '%s' has %d characters\n"`
msgstr "%d Zeichen lang ist die Zeichenkette `%s'"</code>


so that the number with $ mark can be given as below:
`msgstr "%d Zeichen lang ist die Zeichenkette '%s'\n"`


<code>msgstr "%2$d Zeichen lang ist die Zeichenkette `%1$s'"</code>
In order to specify the parameter order, the number with $ mark can be given as below:
 
<code>msgstr "%2$d Zeichen lang ist die Zeichenkette '%1$s'\n"</code>




'''Alternatives'''
'''Alternatives'''


In some cases, you may see a string that looks like "<code>%(var)s</code>". This variable can be moved within a string in any order.
In some cases, you may see a string that looks like "`%(var)s`". This variable can be moved within a string in any order.
 
`msgid "String '%(str)s' has %(char)s characters\n"`


<code>msgid "String `%(str)s' has %(char)s characters"</code>
Translated:


<p>Translated: </p>
`msgstr "%(char)s Zeichen lang ist die Zeichenkette '%(str)s'\n"`
<code>msgstr "%(char)s Zeichen lang ist die Zeichenkette `%(str)s'"</code>


No other changes are required.
No other changes are required.


[[Category:Localization]]
[[Category:Localization]]

Revision as of 10:53, 4 April 2020

The Fedora Localization Project - Tips for Translators

Controlling parameters order

When translating, sometimes the translation of a particular string requires different parameter order. But it is usually not allowed to change them in the translated string. There is the workaround to change the order in translation, and it can be found with info gettext command.

For example; in German, this won't work:

msgid "String '%s' has %d characters\n"

msgstr "%d Zeichen lang ist die Zeichenkette '%s'\n"

In order to specify the parameter order, the number with $ mark can be given as below:

msgstr "%2$d Zeichen lang ist die Zeichenkette '%1$s'\n"


Alternatives

In some cases, you may see a string that looks like "%(var)s". This variable can be moved within a string in any order.

msgid "String '%(str)s' has %(char)s characters\n"

Translated:

msgstr "%(char)s Zeichen lang ist die Zeichenkette '%(str)s'\n"

No other changes are required.