![]() |
Web Development »
Applications & Tools »
Tools with source code
Intermediate
License: The BSD License
RC Localization Tool (LocalizeRC)By Konrad WindszusA tool for localizing/translating Resource Scripts |
VC6, VC7, VC7.1, MFC, VS.NET2003, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||
This tool, called LocalizeRC, scans Resource Scripts and extracts the language specific strings into an INI file. This file can be edited with any text editor. It then creates a new Resource Script with the translated strings from the INI file.
Although there is a lot of commercial software for translating resource files, I started developing LocalizeRC, because the other tools are all very complex and also very expensive. LocalizeRC is very easy to understand and makes it possible to create a translation within minutes! To supply more than one language just create a resource-only DLL from the Resource Script, which is created by LocalizeRC. The only disadvantage of LocalizeRC is that you have to compile the Resource Script for yourself. I will explain later, how to manage that.
First of all you have to create a software program in one language, like you normally do. All your translations start from this original language. My first language is always English, although I'm from Germany, because it is easier to find someone who is able to translate from English to his native language, than from German. But that is up to you...
Then you can start LocalizeRC and create a new workspace within a new folder (e.g. "German") by clicking on New.... As Input RC you should select the Resource Script in original language. For the Language INI and Output RC you should specify any filename for these files within the workspace folder (e.g. "German.ini" and "German.rc"). You can also choose any other folder but I recommend to have these three files in the same folder for reasons of clearness. Then click on the Create/Actualize INI from Input RC button.
Afterwards you can edit your Language INI with your standard editor by clicking the Open INI for Edit button. In the INI file there are two items per line. On the left side of the equals sign stands the original language. The rights side has to be replaced by the new language. You can also deploy this INI file to external translators. In the section [code_page] in the INI file, you can set the codepage that should be used in that RC. For a list of valid codepages look have a look at Links.
When you have finished translating the strings just save that INI file and close the editor. In LocalizeRC you should also check the option Copy Resource Header and "RES" Folder. Then the header "resource.h" and the files within the subfolder "RES" will be copied to the new folder which will later contain the Output RC. Afterwards you should click on the Create Output RC with INI button. Then LocalizeRC automatically creates the Output RC with the translated strings.
If you want to translate to Asian languages, you must perhaps use Unicode RCs, because some of these languages have more than 128/256 characters. Then you have to download the Unicode binary. Please notice that only Windows NT/2000/XP is fully compatible with Unicode.
As a result you should have created a folder with four files and one subfolder:
To use these files in your application, you have to create a resource-only DLL.
I describe these steps for Visual C++.NET (7.0 or 7.1), but it should be very similar in 6.0 and 5.0.
If you have got a MFC application, it will automatically load a satellite DLL if it has the filename ApplicationNameXXX.dll. The ApplicationName should be same name your application has (the filename without the extension .exe) and the XXX is a three-letter language code. MFC attempts to load the resource DLL for each of the following languages in order, stopping when it finds one:
GetUserDefaultUILanguage Win32 API.
GetSystemDefaultUILanguage API. On other platforms, this is the language of the OS itself.
If MFC does not find any satellite DLLs, it uses the resources which are contained in the application itself (independent from the language). To load a language DLL manually, do the following steps before loading any dialog (e.g. in InitInstance). Call LoadLibrary for your language DLL then call AfxSetResourceHandle to make MFC loading all resources from that DLL. At application exit you have to free the language DLL via FreeLibrary.
For an example you can look at the source code of LocalizeRC.
After getting some mails why not including more than one language into one Resource Script and also into one EXE/DLL I will try to explain it here. In old Windows systems (Windows NT/9X/ME) there was an automatic selection of the right language, if more than one language was available in one EXE/DLL. This selection works in most of the cases. But in modern Windows systems (Windows 2000/XP/2003) this automatic selection doesn't work any more because of internal changes (for more information read the KB article 300680). Microsoft recommends to pack only one language into one file and so do I. Even in Windows NT/9X/ME there is no simple solution to override the automatic selection by the OS.
ANSI files create strings with one byte for each character. That means that you can only store up to 256 different characters. That is enough to store the latin alphabet, but not enough for many other languages which uses much more characters. Therefore you need the Unicode format.
Unfortunately Visual Studio up to the current version 2003 isn't able to edit Unicode Resources. It only says: "Opened in another editor." However you can compile those resources without problems. So you must edit the RCs either with Notepad or another editor which is able to read and write Unicode. You find an example about Handling of Unicode Resources at the MSDN Library in the Links section.
General
MSDN Library
- MFC satellite DLLs
- Microsoft Translation Wordlist
- Microsoft Glossaries
- Codepages Supported By Windows
- Handling of Unicode Resources in Visual Studio
- Resource Language Loading Order in Windows 95/NT
- Loading Multilingual Resource on Windows 2000
CodeProject
I want to make LocalizeRC a real open-source software. Please send your additions/modifications and bugreports as well as typos in the website and the program to webmaster@wincd.de. Also send your wishes for the next version. Please supply me with your translation for LocalizeRC. A new icon would also be very nice ;-).
This is the preliminary Todo list for LocalizeRC:
This project is a thank to all the great authors and helpful developers at Codeproject!
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 14 Jan 2004 Editor: Nishant Sivakumar |
Copyright 2003 by Konrad Windszus Everything else Copyright © CodeProject, 1999-2009 Web22 | Advertise on the Code Project |