开发者

asp.net localization question

I have two resource files: Resource1.resx and Resource1.es-mx.resx The default system culture is en-US.

  1. <%@ Page UICulture="es" Culture="es-MX" %> --> still get English version (setting language in the browser doesn't help).
  2. Rename Resource1.es-mx.resx to Resource1.es.resx --> works, S开发者_如何转开发panish.
  3. <%@ Page UICulture="auto" Culture="auto" %>, set Spanish in the browser, resource Resource1.es-mx.resx --> Spanish.

Could you explain to me what happens in the first case? Why English?


Why English? There are no Spanish country-neutral resources and you ask specifically for them. So it falls back to neutral resources (which happens to be English in your case).

You should do that the other way round: name resources file Resource1.es.resx and ask for specific UICulture: UICulture="es-MX" if you have to. In such case, if country-specific resources are not found, it will fall back to Spanish country-neutral resources (es).
I am not aware of your use case, but hard-coding cultures is not really good idea... You really should think about using auto here.


Have you tried UICulture="es-mx"? I believe, but I'm not 100% sure, that if the second part of the locale is specified on the resource file, it is only used where both parts are specified.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜