Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
swdev:dotnet:localization_using_resx_files [2011/07/14 15:52] smayr |
swdev:dotnet:localization_using_resx_files [2013/12/16 15:26] (current) smayr |
||
---|---|---|---|
Line 8: | Line 8: | ||
* Set Access Modifier to '' | * Set Access Modifier to '' | ||
* Add strings to the Resource file. Eg: '' | * Add strings to the Resource file. Eg: '' | ||
- | * Create other resources files for other languages. For example: | + | |
+ | | ||
* '' | * '' | ||
* '' | * '' | ||
+ | * Set Culture before calling anything else in the application. Modify '' | ||
+ | using System; | ||
+ | using System.Collections.Generic; | ||
+ | using System.Linq; | ||
+ | using System.Windows.Forms; | ||
+ | namespace LocalizedAppWinForms | ||
+ | { | ||
+ | static class Program | ||
+ | { | ||
+ | public static System.Resources.ResourceManager resmgr; | ||
+ | |||
+ | /// < | ||
+ | /// The main entry point for the application. | ||
+ | /// </ | ||
+ | [STAThread] | ||
+ | static void Main() | ||
+ | { | ||
+ | // Sets the UI culture | ||
+ | // | ||
+ | // | ||
+ | System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(" | ||
+ | // | ||
+ | |||
+ | // Load localized resources | ||
+ | resmgr = new System.Resources.ResourceManager( | ||
+ | " | ||
+ | System.Reflection.Assembly.GetExecutingAssembly() | ||
+ | ); | ||
+ | |||
+ | Application.EnableVisualStyles(); | ||
+ | Application.SetCompatibleTextRenderingDefault(false); | ||
+ | Application.Run(new frmMain()); | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | * Localize controls. For example, using form '' | ||
+ | private void frmMain_Load(object sender, EventArgs e) | ||
+ | { | ||
+ | LoadResources(); | ||
+ | } | ||
+ | |||
+ | private void LoadResources() | ||
+ | { | ||
+ | // Optional method to load resources local to this form | ||
+ | // | ||
+ | // " | ||
+ | // System.Reflection.Assembly.GetExecutingAssembly() | ||
+ | //); | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | // | ||
+ | |||
+ | // Method to load global resources (defined in Program.cs file) | ||
+ | lblFirstName.Text = Program.resmgr.GetString(" | ||
+ | lblLastName.Text | ||
+ | lblPatient.Text | ||
+ | btnClose.Text | ||
+ | } | ||
+ | </ | ||
= WPF Localization = | = WPF Localization = | ||
* Create WPF Application (eg '' | * Create WPF Application (eg '' | ||
Line 687: | Line 750: | ||
} | } | ||
</ | </ | ||
+ | |||
= Reference Material = | = Reference Material = | ||
Line 694: | Line 758: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[swdev: |