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 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示