使用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 /stories-internationalization
从该文章:
应用就绪后,您可以使用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
翻译完成后即可提供:
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屋!