简体   繁体   English

模板外的 Angular i18n 翻译等

[英]Angular i18n Translation outside template and more

I have a few questions about i18n implementation.我有几个关于 i18n 实现的问题。 After searching across documentation and across all the web, there are still some open issues for me.在搜索文档和所有网络后,我仍然有一些未解决的问题。

  1. Can I use a translate service from i18n to localize strings outside of templates?我可以使用 i18n 的翻译服务来本地化模板之外的字符串吗? (aka ts files) (又名 ts 文件)
    In AngularJs there was $translate service for that purpose.在 AngularJs 中有用于此目的的$translate服务。
  2. Is it possible to use i18n both JIT and AOT ?是否可以同时使用 i18n JITAOT it will be great to localize the static strings and let the dynamic ones to get translated on build time.本地化静态字符串并让动态字符串在构建时得到翻译会很棒。
  3. I already implemented localization with ngx-translate.我已经用 ngx-translate 实现了本地化。 Did someone use both ngx-translate and i18n in its projects?有人在其项目中同时使用 ngx-translate 和 i18n 吗?

Thanks in advance for your answers!提前感谢您的回答!

As per my knowledge,据我所知,

Answer 1. yes we can use translate service from i18n to translate .ts files string but this is available from v9.回答 1. 是的,我们可以使用 i18n 的翻译服务来翻译 .ts 文件字符串,但这在 v9 中可用。 Till version 8 .ts file translation is not present i suppose.我想直到版本 8 .ts 文件翻译不存在。 Following link for support: angular-localize以下支持链接: angular-localize

Answer 2. Yes, we can use i18n in both JIT and AOT mode.回答 2. 是的,我们可以在 JIT 和 AOT 模式下使用 i18n。 In AOT mode you are already creating application bundle per locale and as per user changes, you will load respective bundle.在 AOT 模式下,您已经在按区域设置创建应用程序包,并且根据用户更改,您将加载相应的包。 And in JIT mode you have to re-bootstrap the complete application after translating as per user choose locale.在 JIT 模式下,您必须在根据用户选择的语言环境进行翻译后重新引导整个应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM