0

I am developing a small project about using multiple language.

I have three resource files

  1. MainForm.resx // Default version => English
  2. MainForm.US.resx // English version

I define enter image description here

  1. MainForm.JP.resx // Japanese version

I define enter image description here

I want to get value of each variable (btnCancel, btnLogin, lbPassword, lbUsername, ...)

Now, I do

  • From MainForm.US.resx, I build to MainForm.US.designer.cs (MainForm_US class)
  • From MainForm.JP.resx, I build to MainForm.JP.designer.cs (MainForm_JP class)
  • I make another class MainFormResource.cs. Here, I will check Thread.CurrentThread.CurrentUICulture.Name value
  • If is equal "ja-JP", I get value from MainForm.JS.designer.cs (MainForm_JP class)

  • If is equal "en-US", I get value from MainForm.US.designer.cs (MainForm_US class)

But if my project is large, it will take me more time to do that.

How should I do to get the value of lbUsername, lbPassword, ...?

p/s: I use Windows Form Application in Visual Studio Ultimate 2012

GSP
  • 574
  • 3
  • 7
  • 34

1 Answers1

0

When creating RESX files you only need to activate the automatic code generation on the root file (MainForm.resx in your case).

Visual Studio will generate the code which includes the usage of RescourceManager.

The satellite assemblies will also be generated automatically.

So as NightOwl888 already mentioned, you should read the documentation about using Resx files and globalization / localization features of .NET