This project is a small demo to show how VC++ can be used for localization of existing products.
Windows 2000 is the suggested OS, as it was completely built on Unicode, and though NT was built on Unicode too, using its full capabilities is difficult. Visual Studio and Visual C++ were used to implement this tool.
Japanese language is used as an example to implement the case.
Before we get our hands dirty, let us understand the distinction between Internationalization and Localization.
Internationalization versus Localization
For the software development process, internationalization means to prepare an application so that the code does not need to be modified each time an additional language is to be displayed. Separate files contain all of the translatable information.
Localization of an application means to change it to be able to handle a particular language and locale. To localize a program that has already been internationalized involves no changes to the source code. Instead, translatable files are sent to the product or a contractor translation agency for modification.
For a system to support multiple languages, we need to:
- Windows 2000 or XP.
- Visual Studio and Visual C++.
Setting up Windows 2000 or XP
Step 1: Install the Japanese language pack.
Navigate to Start menu->Control Panel->Regional Options->General. Once in the General tab, check the check box left to the Japanese language from the language settings for the System tab.
Step 2: Setting the input locale.
Navigate to Start menu->Control Panel->Regional Options->Input Locale. Under the Installed Input Locales section, click Add. From the Input Locale drop down list, select Japanese, and for the Keyboard Layout/IME drop down box, select Japanese Input System (MS-IME2000).
Step 3: Setting the default locale.
In the Control Panel - Regional Options, under the General tab, scroll down the list for Language Settings for the System. Highlight Japanese, and click Set Default. Once done, verify it did not change your Input Locale default input language. Click OK.
Setting up Visual C++ for Unicode compilation
Step 1: To Unicode enable a project in VC++: in the VC++ IDE, navigate to Project->Settings->C++, in the Preprocessor definitions section, insert
WIN32,_DEBUG,_WINDOWS,_AFXDLL,_UNICODE, as normal MFC uses
_UNICODE has been defined for your project, a few steps need to be taken to ensure that string handling is done properly.
The first thing you need to understand is that the use of a
char* for strings is no longer valid.
TCHAR should be used in place of this. However, for binary data processing, use of
typedefed as an unsigned char) are still OK.
- Except for database class member functions, all MFC functions are Unicode-enabled, including
CString also provides Unicode/ANSI conversion functions.
- The run-time library supplies Unicode versions of all string-handling functions. (The run-time library also supplies “portable” versions suitable for Unicode or for MBCS. These are the
- TCHAR.H supplies portable data types and the
_T macro for translating literal strings and characters. See Generic-Text Mappings in TCHAR.H.
- The run-time library provides a wide-character version of
wmain to make your application “Unicode-aware.”
Step 2: Navigate to the Link tab and select Output in the drop down list in the Category section, and specify
wWinMainCRTStartup as the entry point for the program, in the Entry-point symbol edit box.
Hurry !!! Now, we are all set to build a small application with a dialog box which accepts Japanese language codes and outputs the same text in the output window.
LPWSTR lpString = new WCHAR[MAX_PATH];
::GetWindowTextW(pWnd->m_hWnd, lpString, MAX_PATH);
LPWSTR caption = A2W("Caption");
HWND hWnd = this->m_hWnd;
MessageBoxW(lpString, caption, MB_OK );
The Operating System is responsible for loading the language specific resources.
This project does not demonstrate the conversion of the file dialog and the titles in the application as this is all part of the Windows Common Dialog library.