简体   繁体   English

切换语言后重新加载页面或动态更新内容?

[英]Reload page or dynamically update content after switch language?

I'm struggling with design of i18n handling, what should we do after user has change the language?我正在努力设计 i18n 处理,用户更改语言后我们应该做什么?

  1. Reload the browser with the selected language使用所选语言重新加载浏览器
  2. Dynamically update the labels and other translatable things without a refresh无需刷新即可动态更新标签和其他可翻译的内容

Can anyone give any suggestion on this?任何人都可以对此提出任何建议吗?

BTW, you can think we are using (Angular, React, or Vue) building a SPA project, the project size won't be very big like an E-commerce portal顺便说一句,你可以认为我们正在使用(Angular、React 或 Vue)构建一个 SPA 项目,项目规模不会像电子商务门户那样大

Possible solutions with i18n ( you will need reload page when language is changed, angualr i18n can't update displayed data in runtime ): i18n 的可能解决方案(语言更改时需要重新加载页面,angualr i18n 无法在运行时更新显示的数据):

  1. Use some subdomain like en.domain.com & fr.domain.com and when language changed navigate user使用一些子域,例如 en.domain.com 和 fr.domain.com,当语言改变时导航用户
  2. Using localStorage (or other storage) for storing selected language使用 localStorage(或其他存储)存储所选语言
  3. Use some prefix (like in first) domain.com/en OR domain.com/fr使用一些前缀(如第一个)domain.com/en 或 domain.com/fr

With using ngx-translate u can saw actually language when it changed (runtime updated).通过使用 ngx-translate,您可以在语言发生变化(运行时更新)时看到实际的语言。

Thanks!谢谢!

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

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