每个区域的 ASP.NET 资源文件全球化和本地化
我正在开发一个需要支持多种语言的网站。
我知道我可以为每种文化设置一组单独的资源文件,并使用它来管理不同的语言,例如,当用户选择法语时,将 UiCulture 设置为法语,ASP.NET 将获取法语资源文件。
我的问题是,我可能必须支持加拿大版本的网站的法语和欧洲版本的网站的法语。由于加拿大市场与法国市场不同,文本会略有不同。
有没有办法使用上述 UiCulture 支持两份“法语”资源文件副本 - 一份用于加拿大,一份来自法国?
I am developing a website which needs to support multiple langauges.
I know that I can a seperate set of resource files for each culture and use that to manage the different languages e.g. when a user selects French set the UiCulture to be french and ASP.NET will pick up on the french resource files.
My problem is that I may have to support French for a Canadian version of the site and french for a European version of the site. The text will be a bit different as the Canadian market is different from the french one.
Is there a way I can support two copies of "French" resource files - one for Canada and one from France using the UiCulture described above?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于加拿大法语,有专门可用的文化设置,
fr-CA
。你只需要设置它。For Canadian french, there is culture settings available specifically for that,
fr-CA
. You just need to set that.要补充 Muhammad 所说的内容,您需要创建两个资源文件,例如名为 Resources.fr.resx 和 Resources.fr-CA.resx。此外,您还需要通过将其设置为“自动”来实际检测 uiCulture。
就是这样。您可能会考虑添加第三个(Resources.fr-FR.resx),它将是通用法语资源文件的副本,但实际上这不是必需的。
顺便提一句。请注意,用户可能在他/她的网络浏览器中仅设置了“FR”。在这种情况下,无论他/她在哪里,都会显示默认法语。我认为这没什么大不了的,但您可能需要实际记录这一点(如何根据浏览器适当地设置 Accept-Language )。
To add to what Muhammad said, what you need is to create two resource files named for example Resources.fr.resx and Resources.fr-CA.resx. Also you need to actually detect uiCulture by setting it to "auto".
That's it. You might think of adding the third one (Resources.fr-FR.resx) that would be the copy of generic French resource file but actually that is not necessary.
BTW. Please mind that user may have set just "FR" in his/her web browser. In that case wherever he/she is, default French would be shown. I don't think this is really big deal but you might need to actually document this (how to set Accept-Language appropriately depending on the browser).