714
edits
mNo edit summary Tag: 2017 source edit |
|||
| Line 17: | Line 17: | ||
= | =国际化(i18n)开发原则= | ||
在 Dolibarr 代码中,翻译是通过调用 $langs 对象上的方法来完成的,该方法的参数是要翻译的字符串的键。$langs 对象包含用户语言的定义。它在所有页面中都有定义。 | |||
有两种方法: | 有两种方法: | ||
< | <syntaxhighlight lang="ini"> | ||
$langs->trans('TRAD_STRING'); | $langs->trans('TRAD_STRING'); | ||
</ | </syntaxhighlight> | ||
此方法返回键TRAD_STRING的翻译,并将结果编码为HTML实体,以允许在HTML页面上正确显示(甚至使用特殊字符)。 | 此方法返回键TRAD_STRING的翻译,并将结果编码为HTML实体,以允许在HTML页面上正确显示(甚至使用特殊字符)。 | ||
< | <syntaxhighlight lang="ini"> | ||
$langs->transnoentitiesnoconv('TRAD_STRING'); | $langs->transnoentitiesnoconv('TRAD_STRING'); | ||
</ | </syntaxhighlight> | ||
此方法返回键TRAD_STRING的翻译,但结果是没有特定编码的已翻译字符串(字符串在内存中存储为UTF-8格式)。 | 此方法返回键TRAD_STRING的翻译,但结果是没有特定编码的已翻译字符串(字符串在内存中存储为UTF-8格式)。 | ||
| Line 40: | Line 39: | ||
Example: | Example: | ||
< | <syntaxhighlight lang="ini"> | ||
print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1")) | print $langs->trans("STRING_TO_TRANSLATE",$langs->transnoentitiesnoconv("STRING_PARAM1")) | ||
</ | </syntaxhighlight> | ||
= 把Dolibarr译成另一种语言 = | =把Dolibarr译成另一种语言= | ||
见 [[Translator documentation]] | 见 [[Translator documentation]] | ||
edits