用于大型应用程序的 ngx-translate
ngx-translate for a large app
我正在使用带有大型 angular app.Currently 的 ngx-translate,我们有 18 个模块,我们估计在生产之前我们将有近 40 个模块。
我将每种语言的翻译保存在单个 json 文件中,即 en.json、fr.json。
我不知道如何处理我的单个 en.json 文件。
注意:我们不想使用模块智能翻译,因为将这么多不同的 json 文件发送给翻译机构对我们来说太棘手了。
在单个文件中处理翻译的最巧妙方法是什么?
除了创建区域,还有其他解决方案吗?
目前我是这样做的:
{
"WELCOME": "Welcome",
"LANGUAGE": "Language",
"LANGUAGE_EN": "english",
"LANGUAGE_ES": "spanish",
"LANGUAGE_PT": "portugese",
"LANGUAGE_RU": "russian",
"LANGUAGE_ZH_HANS": "chinese",
"TITLE_MONITORING": "Monitor",
"TITLE_MAP": "Map",
"TITLE_REPORTING": "Reports",
"TITLE_RULES": "Rules",
"TITLE_SCRIPTS": "Scripts",
"UNASSIGNED_DEVICES": "Unassigned devices"
}
我尝试了以下方法,我更喜欢选项 1 + A。但是例如 JHipster 使用选项 2 + B。这实际上取决于您的喜好...
1) Single JSON file for each language
assets/i18n/en.json
assets/i18n/cs.json
2) Multiple JSON files for each language
assets/i18n/en/moduleA.json
assets/i18n/en/moduleB.json
assets/i18n/cs/moduleA.json
assets/i18n/cs/moduleB.json
A) Without regions
{
"moduleA.componentA.title": "ComponentA title",
"moduleB.componentB.title": "ComponentB title"
}
B) With regions
{
"moduleA": {
"componentA": {
"title": "ComponentA title"
}
},
"moduleB": {
"componentB": {
"title": "ComponentB title"
}
}
}
我正在使用带有大型 angular app.Currently 的 ngx-translate,我们有 18 个模块,我们估计在生产之前我们将有近 40 个模块。 我将每种语言的翻译保存在单个 json 文件中,即 en.json、fr.json。 我不知道如何处理我的单个 en.json 文件。
注意:我们不想使用模块智能翻译,因为将这么多不同的 json 文件发送给翻译机构对我们来说太棘手了。
在单个文件中处理翻译的最巧妙方法是什么? 除了创建区域,还有其他解决方案吗?
目前我是这样做的:
{
"WELCOME": "Welcome",
"LANGUAGE": "Language",
"LANGUAGE_EN": "english",
"LANGUAGE_ES": "spanish",
"LANGUAGE_PT": "portugese",
"LANGUAGE_RU": "russian",
"LANGUAGE_ZH_HANS": "chinese",
"TITLE_MONITORING": "Monitor",
"TITLE_MAP": "Map",
"TITLE_REPORTING": "Reports",
"TITLE_RULES": "Rules",
"TITLE_SCRIPTS": "Scripts",
"UNASSIGNED_DEVICES": "Unassigned devices"
}
我尝试了以下方法,我更喜欢选项 1 + A。但是例如 JHipster 使用选项 2 + B。这实际上取决于您的喜好...
1) Single JSON file for each language
assets/i18n/en.json
assets/i18n/cs.json
2) Multiple JSON files for each language
assets/i18n/en/moduleA.json
assets/i18n/en/moduleB.json
assets/i18n/cs/moduleA.json
assets/i18n/cs/moduleB.json
A) Without regions
{
"moduleA.componentA.title": "ComponentA title",
"moduleB.componentB.title": "ComponentB title"
}
B) With regions
{
"moduleA": {
"componentA": {
"title": "ComponentA title"
}
},
"moduleB": {
"componentB": {
"title": "ComponentB title"
}
}
}