0

I've got a .net 4.0 website that we have 2 copies of it running. One for US based users and another for AU based users. Code is basically the same, the only differences being some text and wording here or there where it references the US versus Australia. Right now I have two copies of the site which is pretty silly. So I want to maintain just one copy and put all these regional text changes in a resource file.

Is it possible to have just a single resource file contain multiple 'languages' or do i need to create a Resource.US.resx and a Resource.AU.resx file? Also, if i do create two files, how do I tell .net which file to use in each site? I assume in the web.config globalization uiCulture & culture='en-AU' or en-US would tell .net which of the two files to use?

1 Answer 1

0

Yes, you are right, you can use Resource.US.resx and a Resource.AU.resx files and tell in web.config globalization uiCulture & culture='en-AU' or en-US

in code:

    string culturePref = [Your setting from web-config]; // "en-US" or "en-EU"
    try
    {
        Thread.CurrentThread.CurrentCulture =
            CultureInfo.CreateSpecificCulture(culturePref);

    }
    catch
    {
        Thread.CurrentThread.CurrentCulture =
            new CultureInfo("en-US");
    }
    Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture;
4
  • Thanks - any way to use just one file or do I have to use a separate file for each region?
    – merk
    Jun 11, 2013 at 20:05
  • You should use separated files for each region
    – ihorko
    Jun 11, 2013 at 20:20
  • How does this work in code behind? Ideally I would like to have a resource file called Resource.en-us.resx and Resource.en-au.resx but if i do that I have to specify which resource file to use in the code, which means I would have to have 2 codebehind files which defeats the purpose of using the resource files. I could have have 2 resource files called Resource.resx and then put the correct copy in each website. but I'd much rather have 2 distinctly named files and be able to use the same code to read from each file.
    – merk
    Jun 27, 2013 at 22:10
  • nm - looks like there needs to be a default file of Filename.resx and then i can add any culture specific files called Filename.culture.resx
    – merk
    Jun 27, 2013 at 22:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.