From Fedora Project Wiki

m (Change "the" to "a")
m (Add autolang)
 
(3 intermediate revisions by one other user not shown)
Line 1: Line 1:
= The Fedora Localization Project - Tips for Translators =
{{autolang|base=yes}}
 
{{Anchor|parameters}}
{{Anchor|parameters}}
== Controlling parameters order ==
== 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 a workaround to change the order in translation, and it can be found with `info gettext` command.
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 a workaround to change the order in translation, and it can be found with <code>info gettext</code> command.


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


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


In order to specify the parameter order, the number with $ mark can be given as below:
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>
<pre>msgstr "%2$d Zeichen lang ist die Zeichenkette '%1$s'\n"</pre>




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


In some cases, you may see a string that looks like "`%(var)s`". This is called a variable and can be moved within a string in any order.
In some cases, you may see a string that looks like <code>%(var)s</code>. This is called a variable and can be moved within a string in any order.


`msgid "String '%(str)s' has %(char)s characters\n"`
<pre>msgid "String '%(str)s' has %(char)s characters\n"</pre>


Translated:  
Translated:  


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


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


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

Latest revision as of 14:53, 29 July 2020

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 a 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 is called a variable and 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.