Jump to: navigation, search
no edit summary
= How to allow translations =
Gramps is a fully-internationalized application with translations in many languages. All code which presents text to users must provide for that text to be translated. Fortunately, Gramps provides an extension of [ gettext] which makes this fairly painless.  == Simple strings == First, alias the gettext function from the single localization instance:
from gramps.gen.const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
In this example, Gramps will attempt to translate the string. If a translation exists, the call to the function will return the translation. If a translation does not exist, the original string is returned.
== Plurals ==
In some strings, it's necessary to specify different translations depending upon the number of an argument. For example,
_("George Smith and Annie Jones have %(num)d child", "George Smith and Annie Jones have %(num)d children", n) % {num : n}
== Context ==
Sometimes a word in English can have different meanings, for example, "rest" can mean either "what's left" or "take a nap".
We're making sure that the translators know the context of the string. The context is made available to the translators in Weblate, but is not displayed to the user.
== Comments ==
A note can be passed to the translators by including a comment in the code on the line before the translated string. This comment must begin with the string "Translators:" and may be multi-line.
_("short string")
== Glade files ==
Strings can be marked as translatable in the "Edit Text" dialog in the Glade editor. Context and comments can also be added.

Navigation menu