[RESOLVED]Issue with localiztion using resource files..MVC3

We are using ASP.NET MVC 3 web application and we recently implemented localization with the help of resource files.

It worked earlier without any issues, but now somehow it has broken. When I tried to debug the issue I am unable to find the root cause.

while debugging we are getting the right locale string (like de or ja) but the value resourcecultureinfo is coming null when I kept breakpoint in resource designer file.

Please help me getting this solved. I am pasting my code where we set the CurrentUICulture.

Note:We are using PublicResXFileCodeGenerator for main resource files and for language specific resource(.de) file we are not using any codegeneration option.

private void EnsureUICulture()
        {
            var locale = (String)UserAdaptor.getUserState().get("CTX_Locale");
            if (!string.IsNullOrEmpty(locale))
            {
                try
                {
                    System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(locale);
                }
                catch (ArgumentException)
                {
                    TraceUtil.TraceInformation("The specified language {0} is not supported or invalid", locale);
                }
            }
        }

Hi,

You can try setting CurrentCultrue also:

Thread.CurrentThread.CurrentCulture = ystem.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(locale);

And please refer to the sample which might help you understand which step are lost:

http://www.chambaud.com/2013/02/27/localization-in-asp-net-mvc-4/

http://stackoverflow.com/questions/13379633/cannot-get-localization-working-in-mvc-4

Leave a Reply