Support for multiple languages ​​in the Winforms application

I almost finished my C # application; the only thing left to do is implement support for several languages.

I have already created resource files that contain lines for several languages ​​for all the text displayed on the screen.

An example of my English resource file:

Name                    |  Value                       | Comment
------------------------------------------------------------------------------
lblName                 |   Name:                      |  Name EN

An example of my Dutch resource file:

Name                    |  Value                       | Comment
------------------------------------------------------------------------------
lblName                 |  Naam:                       | Name NL

How to bind a field Valueto Textmy property Label( lblName)?

I am using the .NET Framework 3.5.

+5
source share
3 answers

I know this question has long asked a question, but since there was no answer here, I suggest:

#, ResourceManager. . . switch if ( ) . , GetString(), , , , - lblName.

N.B: , .

string selectedLanguage = comboBoxLang.Text; // Comes from a menu option
string resourceFile = string.Empty;

/***/
Logic to retrieve the proper resourceFile depending on the selectedLanguage.
/***/

ResourceManager rm = new ResourceManager(resourceFile, Assembly.GetExecutingAssembly());

// Set your label text.
lblName.Text = rm.GetString("lblName");
0

:

<asp:Label runat="server" Text="<%$ Resources:DutchLanguage, Value %>"></asp:Label>
-2

.

.

.

.

-3

All Articles