使用 Angular-cli 在 Angular2 中进行本地化 [英] Localization in Angular2 using Angular-cli
问题描述
使用 Angular-cli 时,Angular 2 是否有本地化工具?
Is there a tool for localization in Angular 2 when using Angular-cli?
我遇到了这个链接(从 11 月开始)声明现在,您无法在翻译的应用程序中使用 CLI",因此无法在我的应用程序中使用 i18n 工具.
I ran into this link (from November) stating that "right now, you can’t use the CLI in translated applications" so the i18n tool can't be used in my application.
还有其他方法可以将应用程序翻译成不同的语言吗?
Is there another way to translate the application to different languages?
(我使用的是 webpack,而不是 systemJs)
(I'm using webpack, not systemJs)
推荐答案
Angular CLI wiki 中有一个故事应该可以帮助您:
There is a story in the Angular CLI wiki which should help you:
https://github.com/angular/angular-cli/wiki/故事-国际化
来自那篇文章:
当您的应用准备就绪后,您可以使用 ng xi18n 命令从模板中提取要翻译的字符串.
When your app is ready, you can extract the strings to translate from your templates with the ng xi18n command.
ng xi18n --output-path src/locale
翻译完成后即可提供服务:
Once you've translated you can serve:
ng serve --aot --locale fr --i18n-format xlf --i18n-file src/locale/messages.fr.xlf
或构建:
ng build --aot --locale fr --i18n-format xlf --i18n-file src/i18n/messages.fr.xlf
这篇关于使用 Angular-cli 在 Angular2 中进行本地化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!