The oslo.i18n library already supports the standard gettext function.
But the “contextual markers” and “plural form” gettext functions are needed for translations. See the Reference - Horizon Translation Wiki.
The standard gettext function support the most of use cases of translations.
But there are two situations needed to be addressed: * different translations of the same English words from different contexts, such as menu item and label; * plural form of some languages like English, different translations are needed for single item or plural items;
In python gettext module, “contextual markers” and “plural form” are supported but without lazy translation support.
The plan is to add the two features with lazy translation support in oslo.i18n library.
oslo.i18n will provide contextual_form and plural_form as additional properties, and abbreviated forms of the two properties as “_C” and “_P”.
Actually we can translate without using “contextual markers” or “plural form”.
But in some cases, “contextual markers” can reduce ambiguities, “plural form” can improve the translation quality.
The new contextual_form and plural_form properties on TranslatorFactory will be provided, and exported from the library.
This spec only covers User Interface strings now, message logs are not affected.
For using the new methods, some gettext call _(“str”) needs to be replaced by _C(“context”, “str”), or _P(“singular”, “plural”, count).
As new methods requires additional arguments, only user cases where new methods can improve the translation quality need to switch to use the new methods.
Most of the code can still use the standard gettext function.
Need to change Jenkins jobs to extract translatable messages with contextual form and plural form.
This spec only adds more functions to oslo.i18n, developers only need to switch to the new functions when improving translations.
If no problem, the code can still use the standard gettext function.
Target Milestone for completion:
New contextual_form and plural_form properties will be provided on TranslatorFactory from oslo.i18n.
Update the developer documentation for oslo.i18n with examples.
Translation team needs to translate “contextual markers” and “plural form” gettext message if used by developers.
This work is licensed under a Creative Commons Attribution 3.0 Unported License. http://creativecommons.org/licenses/by/3.0/legalcode