asp.net localization question
I have two resource files:
Resource1.resx
and Resource1.es-mx.resx
The default system culture is en-US
.
<%@ Page UICulture="es" Culture="es-MX" %>
--> still get English version (setting language in the browser doesn't help).- Rename
Resource1.es-mx.resx
toResource1.es.resx
--> works, S开发者_如何转开发panish. <%@ Page UICulture="auto" Culture="auto" %>
, set Spanish in the browser, resourceResource1.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.
精彩评论