typescript Angular - 国际化 (i18n)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35506628/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Angular - internationalization (i18n)
提问by muetzerich
What is the best way to implement the internationalization for a angular application at the moment?
目前实现角度应用程序国际化的最佳方法是什么?
回答by Herman Fransen
The official i18n angular2 will be implemented in one of the rc release before the final release. It also will be more advanced than the current solutions.
官方 i18n angular2 将在最终版本之前在其中一个 rc 版本中实现。它也将比当前的解决方案更先进。
More info how the new concept of i18n works in angular2:
https://lingohub.com/blog/2015/03/angular-2-i18n-update-ng-conf-2015
有关 i18n 的新概念如何在 angular2 中工作的更多信息:https://lingohub.com/blog/2015/03/angular-2-i18n-update-ng-conf-2015
UPDATE 6 SEPTEMBER 2016:
2016 年 9 月 6 日更新:
Support for i18n is now official in Angular 2 RC6
Angular 2 RC6 现在正式支持 i18n
Official release blog:
https://angularjs.blogspot.nl/2016/09/angular-2-rc6_1.html
官方发布博客:https:
//angularjs.blogspot.nl/2016/09/angular-2-rc6_1.html
A sample of internationalization with Angular 2 RC6
https://github.com/StephenFluin/i18n-sample
Angular 2 RC6 国际化示例
https://github.com/StephenFluin/i18n-sample
回答by Angular University
At the moment the best alternative is is to use ng2-translate, which is a port to Angular 2 of the well known ng-translate. This will likelly cover the majority of use cases.
目前最好的选择是使用ng2-translate,它是众所周知的 ng-translate 的 Angular 2 的端口。这可能会涵盖大多数用例。
Later for Angular 2 there will be an official i18n implementation.
稍后 Angular 2 将有一个官方的 i18n 实现。
回答by Andrei Zhytkevich
According to change log https://github.com/angular/angular/blob/master/CHANGELOG.md, a big piece of i18nwas introduced in Angular 2 RC5:
根据更改日志https://github.com/angular/angular/blob/master/CHANGELOG.md,在Angular 2 RC5 中引入了一大块i18n:
i18n: merge translations 7a8ef1e
i18n:合并翻译7a8ef1e
Unfortunately, I still don't observe any useful documentation.
不幸的是,我仍然没有观察到任何有用的文档。
However, according to https://github.com/angular/angular/issues/9104, the simple cases are already covered
但是,根据https://github.com/angular/angular/issues/9104,已经涵盖了简单的情况
{{ 'TRANSLATION_ID' | translate }}
Search this document https://docs.google.com/document/d/1mwyOFsAD-bPoXTk3Hthq0CAcGXCUw-BtTJMR4nGTY-0/editfor {{ 'TRANSLATION_ID' | translate }}
for more details.
搜索这个文件https://docs.google.com/document/d/1mwyOFsAD-bPoXTk3Hthq0CAcGXCUw-BtTJMR4nGTY-0/edit了{{ 'TRANSLATION_ID' | translate }}
更多的细节。