0
votes

I have a very strange problem using resource files.

I have an ASP.NET web application with a lot of aspx sites. I have generated local resource files for every aspx page and did copy/rename and then did translations. Now i have for instance page SamplePage.aspx with resource files SamplePage.aspx.resx (original, in Croatian) and SamplePage.aspx.en.resx (English translation).

When I change the currentculture/currentuiculture in code behind, everything works mostly great - the words are loaded from the resx file of the newly selected region, however some parts remain untranslated and are loaded from another resx file.

I have noticed it were only asp:dropdownlists, asp:radiobuttons and asp:buttons which didn't translate well, all labels and paragraphs are OK.

Those controls have meta:resourcekey tags set correctly as if I change for example one button's text to something else in the resource file the change is there and visible online, but it is still being loaded from the wrong resource file..

What could be causing the problem?

Does it have anything to do with where I change the region? it is currently in OnInit.

protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        string culture = "hr-HR";
        //string culture = "en-US";

        Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(culture);
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(culture); 
    }
1

1 Answers

0
votes

In the following example (VB.NET) the language is set in Global.asax

Sub Application_BeginRequest(sender As Object, e As EventArgs)
    Dim c As New CultureInfo("en-US")
    Thread.CurrentThread.CurrentCulture = c
    Thread.CurrentThread.CurrentUICulture = c
End Sub

Generally you should only have 1 .resx file per language for the whole Web Application.