实现在ASP.NET应用程序中的多语言的最佳方法 [英] Best way to implement a multilingual in ASP.NET application

查看:287
本文介绍了实现在ASP.NET应用程序中的多语言的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面的东西/行为预计将在多国语言的应用程序。

The following things/behaviors are expected in multi lingual application.

  1. 要选择正确的资源,为登录用户的语言
  2. 在该字符串的排序应根据用户的语言出现。(例如:如果瑞典的用户,瑞典字母应该在ž命令后)
  3. 的日期时间格式验证应根据用户的语言发生。 (例如:FR-FR的用户可以进入DD / MM / YYYY和en-US用户可以输入MM / DD / YYYY)
  4. 在小数再次确认应根据用户的语言发生(例如:12,5是有效的法语,而12.5无效)

现在的问题是什么是处理这个的最好方法。

Now the question is what is the best way to handle this.

方法一:

  1. 设置页面的文化和页面的UICulture - 这样的App_GlobalResources文件被拾起,并在网格十进制值的格式是否正确
  2. 在编写自定义的方法来激发验证以下
    • 日期时间
    • 在小数
  1. Set the page culture and page UICulture – so that the App_GlobalResources are picked up and decimal values in grid are correctly formatted.
  2. Write custom methods to fire validation for the following
    • Datetime
    • Decimal

方法2:

  1. 设置当前线程的文化,并让这种处理好以下几个{是否Web应用程序的每个用户都有自己的文化在这种情况下,是否设置正确?}

方法3:

  1. 初始化根据用户的浏览器文化在web.config中,让应用程序选秀权文化的全球化属性

  1. Initialize the globalization attribute in web.config and letting the application pick culture based on the user’s browser culture

<globalization uiculture="auto" culture="auto" enableClientBasedCulture ="true"/>

请让我知道,如果有更好的选择,我们应该如何处理解决了上述的方法,例如问题或利弊。

Please let me know if there are better alternatives and how should we approach solving such problems or the pros and cons of the above approaches.

推荐答案

重载InitializeCulture()页面事件。使用基于autheticated用户,它存储了currentliy选择文化对话var和在事件处理程序复位两个Thread.Culture和的UICulture。

Overload the InitializeCulture() page event. Use a session var based on the autheticated user, which stores the currentliy selected culture and reset both Thread.Culture and UICulture in the event handler.

据我所知,这些转换问题或toString()方法的格式问题,不应该存在。当前线程文化将处理所有的为您服务。

As far as I know, these conversion issues or ToString() format issues should no exist. The current thread culture will handle all for you.

某些资源:
演练:使用资源本地化与ASP.NET
如何:将文化和UI文化的ASP .NET网页全球化

Some resources:
Walkthrough: Using Resources for Localization with ASP.NET
How to: Set the Culture and UI Culture for ASP.NET Web Page Globalization

这篇关于实现在ASP.NET应用程序中的多语言的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆