Translation system: Difference between revisions

m
no edit summary
mNo edit summary
Tag: 2017 source edit
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
<!-- BEGIN origin interlang links -->
<!-- You can edit this section but do NOT remove these comments
    Links below will be automatically replicated on translated pages by PolyglotBot -->
[[fr:Système_de_traduction]]
[[es:Sistema_de_traducción]]
[[zh:翻译]]
<!-- END interlang links -->
{{TemplateDocDevEn}}
{{TemplateDocDevEn}}


Line 10: Line 18:


There are two methods:
There are two methods:
<source lang="ini">
<syntaxHighlight lang="ini">
  $langs->trans('TRAD_STRING');
  $langs->trans('TRAD_STRING');
</source>
</syntaxHighlight>
This method returns the translation of key TRAD_STRING, and encodes the result into HTML entities to allow to display correctly (even with special characters) on an HTML page.
This method returns the translation of key TRAD_STRING, and encodes the result into HTML entities to allow to display correctly (even with special characters) on an HTML page.
<source lang="ini">
<syntaxHighlight lang="ini">
  $langs->transnoentitiesnoconv('TRAD_STRING');
  $langs->transnoentitiesnoconv('TRAD_STRING');
</source>
</syntaxHighlight>
This method returns the translation of key TRAD_STRING, but the result is the translated string with no particular encoding (string is stored in UTF-8 in memory).
This method returns the translation of key TRAD_STRING, but the result is the translated string with no particular encoding (string is stored in UTF-8 in memory).


Line 24: Line 32:
Note: If, as arguments, you use a string that is itself a translated string, you must use method $langs->transnoentitiesnoconv, otherwise the string will be encoded twice.
Note: If, as arguments, you use a string that is itself a translated string, you must use method $langs->transnoentitiesnoconv, otherwise the string will be encoded twice.
Example:
Example:
<source lang="ini">
<syntaxHighlight lang="ini">
  print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1"))
  print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1"))
</source>
</syntaxHighlight>


= Translate Dolibarr into another language =
= Translate Dolibarr into another language =
See page [[Translator documentation]]
See page [[Translator documentation]]