简体   繁体   English

在运行时使用 i18n 翻译 Angular 8 应用程序

[英]Translate Angular 8 application using i18n at runtime

I am developing a web app and I need to add multi-language support.我正在开发一个网络应用程序,我需要添加多语言支持。 I went through the Angular documentation and I noticed that the translation was occurring at build time.我浏览了 Angular 文档,我注意到翻译是在构建时进行的。 I was curious if we can develop it in a way that the app translates into different a language at run-time.我很好奇我们是否可以以一种应用程序在运行时翻译成不同语言的方式来开发它。 I did some research but I could not find a proper answer.我做了一些研究,但找不到正确的答案。

So my question is, can I add at dropdown language selector at the top in the menu and change the language during runtime?所以我的问题是,我可以在菜单顶部的下拉语言选择器中添加并在运行时更改语言吗?

The one and only:唯一的:

http://www.ngx-translate.com/ http://www.ngx-translate.com/

Im using it in all of my projects.我在我所有的项目中都使用它。

I don't like the i18n of Angular it need for every language a separated compilation and can't change at runtime.我不喜欢 Angular 的 i18n,它对每种语言都需要单独编译,并且不能在运行时更改。

Demo: https://stackblitz.com/github/ngx-translate/example演示: https : //stackblitz.com/github/ngx-translate/example

I am developing a web app and I need to add multi-language support.我正在开发一个Web应用程序,并且需要添加多语言支持。 I went through the Angular documentation and I noticed that the translation was occurring at build time.我浏览了Angular文档,并注意到翻译是在构建时进行的。 I was curious if we can develop it in a way that the app translates into different a language at run-time.我很好奇我们是否可以以一种在应用程序运行时将其翻译成其他语言的方式进行开发。 I did some research but I could not find a proper answer.我做了一些研究,但找不到正确的答案。

So my question is, can I add at dropdown language selector at the top in the menu and change the language during runtime?所以我的问题是,我可以在菜单顶部的下拉语言选择器中添加语言,并在运行时更改语言吗?

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

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