Click here to Skip to main content
15,891,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have another qus
i converted all the form in resx file now how to use all resx file at intallation time when user select a particular language becaz i have 20 forms in my application so can we pass each resx file for that?
Posted

1 solution

First you need to define the CultureInfo, you can either use the system value or define it separately;
CultureInfo currentCulture = Thread.CurrentThread.CurrentUICulture; //Defined by the system
CultureInfo currentCulture = new CultureInfo("fr-FR"); //Manually Defined French Language


The you need a resource manager to get the values from the correct resx file based on the CultureInfo.
Now assume your application is called MyApp and the resx file default is MessageResource
ResourceManager resourceManager = new ResourceManager("MyApp.MessageResource", System.Reflection.Assembly.GetExecutingAssembly());


Then to get the correct value such as a string called "ExitMessage" you use;
resourceManager.GetString("ExitMessage", currentCulture)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900