douluoyou9876 2010-12-07 14:47
浏览 21
已采纳

在双语Web应用程序中存储所选语言的最佳方法是什么?

There are a couple of approaches that come to mind:

  1. GET. I.e. something like www.domain.com, www.domain.com/lang/de

  2. Session.

  3. Database.

I am curious what is an industry standard in this area.

  • 写回答

5条回答 默认 最新

  • douhao1956 2010-12-07 16:51
    关注

    You could change de default application locale in the bootstrap based on the value stored in a session. This way you get more flexibility if you want to add a new language, you just have to create a new translation file if all of you code is built based on the user local. This will also ease the date/time and money display process since those are also based on the locale.

    french locale ie : fr_FR or fr_CA (for french France of french Canada) english locale id : en_US or en_UK (for english United States or english United Kindom)

    and then if you have to display money, the local will set the good money symbol (but won't do the price conversion) (ie fr_FR -> € and fr_CA -> $)

    You could base the default language selection based on the geolocation of the user based on his IP address

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大