翻译: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Template开发文档}} {{Template用户手册}} {{TemplateMainPageZh}} = 国际化(I18N)发展规则 = 在Dolibarr代码中,通过使用对象$langs中可用的方...") |
PolyglotBot (talk | contribs) m (Import interlang links (links to translated versions of this page in other languages) from origin English page "Translation_system".) |
||
| Line 1: | Line 1: | ||
<!-- BEGIN interlang links --> | |||
<!-- Do NOT edit this section | |||
Links below are automatically managed by PolyglotBot | |||
You can edit links on the English source page : Translation_system --> | |||
[[en:Translation_system]] | |||
[[fr:Système_de_traduction]] | |||
[[es:Sistema_de_traducción]] | |||
<!-- END interlang links --> | |||
{{Template开发文档}} | {{Template开发文档}} | ||
{{Template用户手册}} | {{Template用户手册}} | ||
Revision as of 13:21, 23 July 2019
国际化(I18N)发展规则
在Dolibarr代码中,通过使用对象$langs中可用的方法(关键值作为此方法的参数进行翻译)进行翻译。$Langs对象包含使用的语言的定义。此对象始终在所有页面中定义。
有两种方法:
$langs->trans('TRAD_STRING');
此方法返回键TRAD_STRING的翻译,并将结果编码为HTML实体,以允许在HTML页面上正确显示(甚至使用特殊字符)。
$langs->transnoentitiesnoconv('TRAD_STRING');
此方法返回键TRAD_STRING的翻译,但结果是没有特定编码的已翻译字符串(字符串在内存中存储为UTF-8格式)。
这两种方法可以接受用于在翻译的字符串中替换字符串%s的参数。
注意:如果将字符串本身作为参数使用,则必须使用$langs->transnoentitiesnoconv方法,否则字符串将被编码两次。
Example:
print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1"))