简体   繁体   English

i18n Angular 5更改翻译

[英]i18n Angular 5 change translations

i have an Angular 5 CLI project. 我有一个Angular 5 CLI项目。 He works, but I don't know how to change the local by the website. 他在工作,但我不知道如何通过网站更改本地语言。 If I want an English translation, I have to use this command: 如果要英语翻译,则必须使用以下命令:

ng build --aot --locale en --i18n-format xlf --i18n-file src/Ressources/translations/messages.en.xlf --missing-translation error

Or this command for a French translation: 或以下命令进行法语翻译:

ng build --aot --locale fr --i18n-format xlf --i18n-file src/Ressources/translations/messages.fr.xlf --missing-translation error

Etc... However, I have to make this change by a combo box and I don't have any idea how to do it. 等等...但是,我必须通过组合框进行此更改,而且我不知道如何进行更改。

For AOT, after you compile your project for en and fr you should serve in your nginx(or the http server you are using) an instance for each language, for example if your domain is: mydomain.com, it should be served smething like this: mydomain.com/en and mydomain.com/fr. 对于AOT,在为en和fr编译项目后,应在每种语言的nginx(或正在使用的http服务器)中提供一个实例,例如,如果您的域是:mydomain.com,则应像这是:mydomain.com/en和mydomain.com/fr。 Then in your combobox, you just redirect to the desired translation. 然后,在组合框中,您只需重定向到所需的翻译即可。

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

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