Marketing software by a Product based company demands that the application being developed ought to support more than one language to acquire good market. When developing a competitive application, the design aspect must be to implement internationalization support. Every time when the application is released for new language, satellite assembly is created to suuport new language So that the application displays text strings for supported language on User interface correctly. Satellite assembly contains resources required by localization. There are tools available in .NET Framework. This white paper discusses as to how to maintain the localization strings, and automate the generation of satellite assembly as and when required. Resgen.exe is Resource file generator which is a command line tool available in .NET to generate satellite assembly. The resource file generator convert .txt files and .resx (XML-based resource format) files to common language runtime binary .resources files that can be embedded in a runtime binary executable or compiles into satellite assemblies.
Resgen.exe performs the following conversions:
Converts .txt files to .resources or .resx files
converts .resources files to text or .resx files
converts .resx files to text or .resources files
In order for Resgen.exe to be able to parse your input, it is critical that your .txt and resx files follow the correct format. You must specify each name/value pair on a separate line as follows:
name = value
If you use Resgen.exe to convert a .resources file containing objects to a .txt file, all the string resources will be converted correctly, but the data types of the nonstring objects will also be written to the file as string. You will lose the embedded objects in the conversion and Resgen.exe will report that an error occurred in retrieving the resources.
Why "AutoLocalize" is useful
The process of generating the satellite assembly is cumbersome, if the satellite assembly would contain string resources and images. AutoLocalize helps you to automate generating satellite assembly process. When your application has to support a new language all you need to do is 4 steps:
1. Set language setting in Windows(described below)
2. Load the tool (Autolocalize.exe)
3. Key-in language specific strings
4. Generate satellite assembly.
That's all there is to it! You can use the satellite assembly to support new language for your application.
Set Language in Windows
Before localized strings are keyed-in, setting language in Windows is required. Follow the steps to set language.
1. From the Start menu on the windows desktop taskbar, choose Settings, Control Panel
2. Select Regional and Language options
3. In Regional and Language options dialog box, select Languages tab.
4. Click on Details... button
5. In Text Services and Input Languages dialog box, Click on Add.. button in Settings tab.
6. In Add Input Language dialog box, select a language which is going to support by your application.
In our Example we have selected German (Germany). The short form for German "DE" is displayed in "Text Services and Input Languages" Once the setting is done, look at the right side corner on the desktop. The indicative of the language short form will be displayed. In our case "DE" is displayed.
Now the language set up is done in windows.
What Autolocalize does?
Let us explore the advantages that Autolocalize tool should have if it is to prove useful. It uses SQL Server database to maintain string resources. It creates database and a table namely "Localize" and "LanguageSupport" in SQL Server when it is installed. It maintains "LanguageSupport" table to store list of languages that are supported by a software product to create satellite assemblies. It maintains separate table for each language. As and when the new language data is entered, it creates two different tables to store locale keys and values. One table is to store text resources and another is for image resources. But when generating satellite assembly, both text and images resources will be stored in to one assembly. The advantage of using this process is that whenever the new version of software product is released, the new string and image resources can be fed and can generate satellite assembly. On the other hand, maintenance of satellite assembly is easy using this process.
How to use Autolocalize to generate satellite assembly?
File, Tools, Windows and
Help menus. File menu consists of
Text resource and
Image resource options.
Tools menu consists of
Generate resource option. Let us start with
Language Support option. This is the first screen in which language information are keyed-in.
Language Support from menu.
2. Right click mouse
3. Context menu that consists of options
Edit will be displayed.
New. A screen will be displayed like the one shown below.
5. Key-in Language id. (Unique identification for a language. It would be better if you use culture name for language identifier what Microsoft suggests in MSDN. EN-english, DE-German etc.,)
6. Key-in style sheet name which needed to be maintained for a language.
7. Key-in resource file name. This file is used to store string resources when satellite assembly is generated.
8. Key-in name of assembly. Satellite assembly will be created in this name.
9. Key-in resource table name. A table will be created in database to store text resources with this name.
10. Key-in image table name. A table will be created in database to store image resources with this name.
11. Select a location at which the satellite assembly needs to be generated. Here you can give the target path where software product is stored.
12. Default Language. The language to which the software product is developed. Any one language to be set as mandatory.
13. Press TAB key.
14. Press Save & Close button.
In this example we use EN for english. Now the default language is set. To key-in string resources for the language, select EN in combo box displayed at right top corner of main screen.
File, Text resource options from pull down menu. You will be presented with a screen as shown below.
Note: Do not forget to select a language option from combo box (displayed at the top right corner of main screen) to which you are about to key-in text or images. If any language other than default is selected, locale key is taken from default language. You need to key-in only equivalent word.
16. Right click mouse. A context menu will be displayed containing
New, Edit options.
New option. You can see a screen like the one shown below.
18. Key-in a text which would be used as a key for localization in Locale key column.
19. Key-in equivalent language text in
Value in Other Language text box. Obiviously for default language text typed in the both text boxes will be same.
Consider a login page for your application. The screen gets Login Name and Password to authenticate users. If you are developing an application for English language then the text in
Locale key and
Value in other language column would be Login Name. But in case your application has to support German language, then in
Locale key column Login name will be typed and in Value in other language column an equivalent German word will be typed.
Save & Close to save data.
How to save Images?
File, Image resource options from pull down menu. You will be presented with a screen as shown below.
2. Right click mouse. A context menu will be displayed containing
New, Edit options.
New option. You can see a screen like the one shown below.
4. Key-in a name for image which is a key to locate the image in database.
Get Image from file button to select an image to be stored in database.
6. Open dialog box will be displayed.
7. Select an image to be saved.
Save and close button. Once image is saved, the added information will be dispalyed in the main screen as shown below.
How to generate satellite assembly?
File, Tools, Generate resource options from pull down menu. You will be presented with a screen as shown below.
2. Select a language (row) by clicking left mouse key. Selected row is indicated as triangle pointing that row at the left side.
3. Right click mouse. A screen will be displayed as shown below which would contain the language informations like language id, resource file name, name of assembly, resource table in which text resources are stored, image table in which image resource are stored in database.
4. Select a drive and folder in which satellite assembly to be stored.
Generate Resource button.
Note: Make sure that you have set environment variable (path) that points to D:\WINNT\Microsoft.NET\Framework\v2.0.50727 folder. Because autolocalize tool uses al.exe to generate satellite assembly.
6. Now check the folder for satellite assembly. (In this case an assembly will be created in the name of ENGASM.DLL)
Using satellite assembly in your application
In your application, use
System.Reflection namespace to load satellite assembly, and
System.Resource namespace to load string or images from satellite assembly.
System.Reflection.Assembly oA = System.Reflection.Assembly.LoadFile("f:\\resources\\engasm.dll");
rm = new System.Resources.ResourceManager("engres",oA);
You need not to hard code the name of .resource file in source code. This can be specified in app.config/web.config files and you can write a configuration handler to retrieve automatically. You can enhance this tool to suit your needs.