Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I change the current Resource Manager at runtime to switch languages?

I have a C# application and I'm trying to make it support multiple languages by referencing different resx files using the resource manager.

I have this code in my Designer.cs:

        [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
    public static global::System.Resources.ResourceManager ResourceManager {
        get {
            if (object.ReferenceEquals(resourceMan, null)) {
                global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("project.resources.en-US", typeof(resources.en-US).Assembly);
                resourceMan = temp;
            }
            return resourceMan;
        }
    }

How can I switch System.Resources.ResourceManager("project.resources.en-US", typeof(resources.en-US).Assembly) to System.Resources.ResourceManager("project.resources.it-IT", typeof(resources.it-IT).Assembly) at runtime without modifying my Designer.cs code? Is it possible?

This question is related

Edit: To clarify, I realize I'm not supposed to change my designer code, but I'm trying to make it so that I access a different resx file. I apologize if my question was ill-worded, but I guess I don't completely understand what I'm talking about. I'm currently looking into satellite assemblies.

like image 858
Jeffrey Greenham Avatar asked Mar 01 '11 18:03

Jeffrey Greenham


1 Answers

just change current culture info and the job should be done. System.Threading.Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

like image 192
Davita Avatar answered Nov 08 '22 13:11

Davita