3.4.6. 在域中添加语言
前提条件
- 要为域启用国际化,请查看 服务器管理指南。
流程
-
在主题的目录中创建文件
<THEME TYPE>/messages/messages_<LOCALE>.properties
。 将此文件添加到 <
THEME TYPE>/theme.properties
中的locales
属性。要使语言提供给用户登录
、帐户和
电子邮件
,主题必须支持该语言,因此您需要为这些主题类型添加您的语言。例如:要将 Norwegian 转换添加到
mytheme
theme create filethemes/mytheme/login/messages/messages_no.properties
中以下内容:usernameOrEmail=Brukernavn password=Passord
如果省略了消息的翻译,将使用英语。
编辑
它们/mytheme/login/theme.properties
并添加:locales=en,no
-
为
帐户
添加相同的电子邮件
类型。要执行此操作,请创建它们/mytheme/account/messages/messages_no.properties
和themes/mytheme/email/messages_no.properties
。这些文件为空将导致使用英语消息。 -
将
themes/mytheme/login/theme.properties
复制到themes/mytheme/account/theme.properties
以及themes/mytheme/email/theme.properties
。 为语言选择器添加翻译。这是通过向英语翻译添加消息来完成的。要执行此操作,请将以下内容添加到
themes/mytheme/account/messages/messages_en.properties
和themes/mytheme/login/messages/messages_en.properties
:locale_no=Norsk
默认情况下,消息属性文件应使用 ISO-8859-1 进行编码。也可以使用特殊标头指定编码。例如,使用 UTF-8 编码:
# encoding: UTF-8 usernameOrEmail=....
其他资源
- 如需有关如何选择当前区域设置的详细信息,请参阅 Locale Selector。