Localtransformer supports visual .NET Localization. With Localtransformer it is possible to localize .NET applications (exe Files) and Dynamic Link Libraries (dll files). Localtransformer extracts resources to be localized from the .NET application including Text,Images and Icons. By building the project Localtransformer automatically creates a satellite assembly and only few lines of code are needed in order to switch to the desired
translation language during runtime.
Please note that "Localizable" property of all windows forms and user controls has to be set to true.
How to localize .NET applications
In order to localize .NET applications the following steps have to be made
Step 1 - Internationalize Application
At first the application should be internationalized. This means that it should be made ready for localization.
This includes that all strings and messages that are to be localized should be put in separate resource files.
Therefore it is necessary to add a "Resources File" to your .NET project. In Visual Studio right click on the project node and select "Add New Item" and then "Resources File". Then , select the new resources file. The resources file ,as you will see in the screen that will be shown, consists of name and value pairs.
The "Name" is the key of the resource item and "Value" its value. In order to localize the messages and strings of the application, you have to add a name and value pair for each one of them. Usually, the name and value of the items are the same and contain the message or string to be localized. This means that for each message or string to be localized in the application , that is not part of the user interface, you have to add a row in the resources file with name and value that corresponds to the message or string to be localized.
Moreover, each image or icon , that is not part of the main user interface has to be added in this resources file.
Step 2 - User Interface Language Switching Code
After making localization ready the application , it is necessary to add code in the application that enables
to switch the language of the user interface. This can be done with a few lines of code :
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(LANGUAGE_CODE)
For example to switch to German (de) we have to write the following code :
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de-DE")
Language switching can be done at runtime adding a method like this:
// Change current language
System.Threading.Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.InvariantCulture;
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo(language_code);
// Populate components
// Initialize UI dynamically calling the Load event handler of the Form
// In this case the Load event handler of the form is MyForm_Load
Step 3 - Code to get localized message or string
After having written the function to switch the user interface culture it is necessary to write a function
in order to get the localized messages and strings. Therefore, it is necessary to use the ResourceManager class
that retrieves resources based on the current user interface culture.
In a separate class for example called "TranslateHelper" we are going to add a ResourceManager class variable as static:
public static System.Resources.ResourceManager rm=null;
Then, during the initialization of our application we will put the following line somewhere:
TranslateHelper.rm = new ResourceManager("MyNamespace.Resource1", this.GetType().Assembly);
"Resource1" is the name of the resources files class that we use in this example and if we are going to use another
name for the resources file we have to substitute it with the new name. The same also with "MyNamespace" which is the default namespace of the project.
Afterwards, in the TranslateHelper class we can insert the following function in order to get the localized
strings or messages:
where "MyImage" is the name of the image in the resources file.
Step 4 - Set Localizable property to true
In order to localize a .NET target it is necessary to set the "Localizable" property of all windows forms and user controls to true.
Step 5 - Run Localtransformer and scan .NET application
After doing all this we have to run Localtransformer and create a new project where we will add the .exe or .dll
file of the application. Localtransformer will scan the application and extract all data to be localized.
Step 6 - Export or Send Project to Translator
The next step is to export the data to be localized (for example as a csv text file) or send the project to the translator
Step 7 - The translator translates the data to be localized
Then , the translator can edit the export file (for example it is possible to edit the exported csv text file in Microsoft Excel) or open the Localtransformer project and translate it within Localtransformer.
Step 8 - Visually localize the application
The next step is to visually localize the application and change for example the length of the label controls so that the translation fits. This can be done by the translator or later by the developers.
Step 9 - The translator sends the translated export file or project back
After having translated the data to be localized the translator should send it back.
Step 10 - Import the localized files from the translator
Then, it is necessary to import the localized file that the translator sent.
Step 11 - Build the application with Localtransformer
In the end , build the application with the use of Localtransformer. Localtransformer will create automatically satellite assemblies.
Visual .NET Localization
In order to visually localize a .NET Windows Form , after selecting it , press the "Start Visual Edit" button.
Then the Windows Form will be shown and you can select each of the controls by clicking on it with the mouse or from Form's controls combobox.
In the properties box you can change any property of the control. Please note though that not all control properties are written to the form's resource file due to limitation of the .NET platform.
Therefore, they cannot be changed. Size, Location and Font control properties though can be changed for sure.
After editing the Windows Form visually it is necessary to press the "End Visual Edit" button.
Then, a new screen will be shown with the visual properties that have been changed. In order to proceed it is necessary to confirm the changes by pressing the "Finish" button.