Question

I have a working resx localization setup with Microsoft MVC4 for base languages such as English, French, German, etc., but I'm trying to extend it to more specific languages such as Simplified/Traditional Chinese.

I have named my files with the recommended naming convention:

SharedStrings.de.resx
SharedStrings.es-es.resx
SharedStrings.es.resx
SharesStrings.fr.resx
SharedStrings.resx
SharedStrings.zh-cn.resx
SharedStrings.zh-tw.resx

Right I am setting the culture in Global.asax.cs in Application_BeginRequest() and doing something like this:

CultureInfo ci = new CultureInfo(CultureInfo.CurrentCulture.Name);
ci = System.Globalization.CultureInfo.GetCultureInfo("zh-tw");
Thread.CurrentThread.CurrentCulture = ci;
Thread.CurrentThread.CurrentUICulture = ci;

When I load the page though it doesn't pick up zh-tw or es-es, but weirdly it does pick up zh-cn, de, en, etc. I'm sort of lost here so I would really appreciate some help.

Was it helpful?

Solution

I finally figured out what the issue was. When I generated the name resx files using Visual Studio 2010 it didn't generate them as an Embedded Resource. The way to fix this is to right click on the resx files that aren't working and select properties. Then change the build action to "Embedded Resource" and also fill in the Custom Tool Namespace, I use "GlobalStr".

I hope my stupidity will help others in the future.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top