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/06/17 11:44] smayr |
swdev:dotnet:localization_using_resx_files [2013/12/16 15:26] (current) smayr |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | = WPF Localization = | + | = Localization |
- | == Localization | + | = WinForms Localization |
+ | * Create WinForms Application (eg '' | ||
+ | * Optionally, create an Resource-only Assembly (eg '' | ||
+ | * Create Resource file in local application or resource-only assembly. | ||
+ | * Add new '' | ||
+ | * Set Access Modifier to '' | ||
+ | * Add strings to the Resource file. Eg: '' | ||
+ | * Autotranslate original English RESX strings using Google Translate and [[http:// | ||
+ | * Create other resources files for other languages not supported in autotranslation. 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 | ||
* Create WPF Application (eg '' | * Create WPF Application (eg '' | ||
* Optionally, create an Resource-only Assembly (eg '' | * Optionally, create an Resource-only Assembly (eg '' | ||
* Create Resource file in local application or resource-only assembly. | * Create Resource file in local application or resource-only assembly. | ||
- | * Add new '' | + | * Add new '' |
* Set Access Modifier to '' | * Set Access Modifier to '' | ||
* Add strings to the Resource file. Eg: '' | * Add strings to the Resource file. Eg: '' | ||
Line 140: | Line 214: | ||
} | } | ||
</ | </ | ||
+ | |||
+ | === Deployment === | ||
+ | * Copy application executable, and localization resource-only assembly, if using one. Eg: '' | ||
+ | * Copy language subfolders with localized resources or resource-only assemblies. Eg: | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * Create an application settings file with default language setting. Eg: File ''// | ||
+ | < | ||
+ | < | ||
+ | <setting name=" | ||
+ | <!--Pick only one value--> | ||
+ | < | ||
+ | </ | ||
+ | <setting name=" | ||
+ | <!--Pick only one value--> | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | . . . | ||
+ | </ | ||
== Localization Sample == | == Localization Sample == | ||
Line 653: | Line 750: | ||
} | } | ||
</ | </ | ||
+ | |||
= Reference Material = | = Reference Material = | ||
Line 660: | Line 758: | ||
* [[http:// | * [[http:// | ||
* [[http:// | * [[http:// | ||
+ | * [[swdev: |