Translation system: Difference between revisions
(Created page with '{{TemplateDocDevEn}} {{ToTranslate}} == Principe développement == Dans le code les traductions se font par appel de methode sur l'objet $langs avec en paramètre la clé de la ...') |
mNo edit summary |
||
| Line 1: | Line 1: | ||
{{TemplateDocDevEn}} | {{TemplateDocDevEn}} | ||
== | == Development rule == | ||
In Dolibarr code source, translations are made by using a method available on object $langs with the key to translate as parameter of this method. The $langs object contains definition of use language. This object is always defined in all pages. | |||
There is 2 methods: | |||
* $langs->trans('TRAD_STRING'); | * $langs->trans('TRAD_STRING'); | ||
This methode return translation of key TRAD_STRING, and encode result into HTML entities to allow to output it correctly (even with special characters) into an HTML page. | |||
* $langs-> | * $langs->transnoentitiesnoconv('TRAD_STRING'); | ||
This method return translation of key TRAD_STRING, but result is translated string with no particular encoding (string is stored in UTF-8 in memory). | |||
This 2 methods can accept arguments that will be used to replaced strings %s found in resulted translated string. | |||
Note: | Note: If, as arguments, you use a string that is itslef a translated string, you must use method $langs->transnoentitiesnoconv, otherwise string will be encoded twice. | ||
print $langs->trans("STRING_TO_TRANSLATE",$langs-> | Example: | ||
print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1")) | |||
== | == Translate Dolibarr into another language == | ||
See page [[Translator documentation]] | |||
Revision as of 22:46, 8 April 2009
Development rule
In Dolibarr code source, translations are made by using a method available on object $langs with the key to translate as parameter of this method. The $langs object contains definition of use language. This object is always defined in all pages.
There is 2 methods:
- $langs->trans('TRAD_STRING');
This methode return translation of key TRAD_STRING, and encode result into HTML entities to allow to output it correctly (even with special characters) into an HTML page.
- $langs->transnoentitiesnoconv('TRAD_STRING');
This method return translation of key TRAD_STRING, but result is translated string with no particular encoding (string is stored in UTF-8 in memory).
This 2 methods can accept arguments that will be used to replaced strings %s found in resulted translated string.
Note: If, as arguments, you use a string that is itslef a translated string, you must use method $langs->transnoentitiesnoconv, otherwise string will be encoded twice.
Example:
print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1"))
Translate Dolibarr into another language
See page Translator documentation