Multilingual Library adds multiple UI languages support to your MFC application. Multilingual library uses resource-only DLLs (sometimes called satellite DLLs) to keep translated resources, automatically selects appropriate language according to Microsoft Windows settings, and automatically generates a menu for inclusion in your application with a list of available languages to allow a user to change the language. The library is quite easy to use as only minimal changes to the source code are required and it works with both exe and DLL files.
On the first run, Library finds available resource-only DLLs in the application directory, makes a list of available languages and then selects the most suitable language according to Microsoft Windows language settings. It loads selected language UI resources from corresponding resource-only DLL and then substitute them for resources in the main exe/dll file. Toolkit saves UI language setting in registry and user can select other languages using menu from your application at any time.
Naming Convention
To use Multilingual Library you have to name satellite DLLs as Filename.LNG, where LNG is a two or three character code that identifies language (For example, English is EN, English-United States is ENU, Russian RU, German ? DE). You can find full list at MSDN Library.
Example:
You want to translate application files below
You have to name Resource-only DLLs in German as
In French it would be
To be found by toolkit, resource-only DLLs should be placed in the same directory as executable files.
Link MFC application to Lingobit Localization Toolkit
1. Add the following line to the beginning of MainFrm.cpp
#include "MultiLang.h
2. Add the following code between BEGIN_MESSAGE_MAP ( CMainFrame , CFrameWnd )
and END_MESSAGE_MAP ()
in MainFrm .cpp
#include "MultiLang.h
ON_COMMAND_RANGE(ID_LANGUAGE_FIRST, ID_LANGUAGE_FIRST+MAX_LANGUAGES, OnLanguageFirst)
ON_UPDATE_COMMAND_UI_RANGE(ID_LANGUAGE_FIRST, ID_LANGUAGE_FIRST+MAX_LANGUAGES, OnUpdateLanguageFirst)
3. Add the following code to the MainFrm.cpp
void CMainFrame :: OnLanguageFirst ( UINT nID ) { MultiLangOnClickMenu ( nID ); AfxMessageBox ( _T ("Please restart application for changes to take effect")); } void CMainFrame :: OnUpdateLanguageFirst ( CCmdUI * pCmdUI ) { MultiLang UpdateMenu ( pCmdUI ); }
4. Add the following lines to the stdafx.h
#define ID_LANGUAGE_FIRST 32000 #define MAX_LANGUAGES 100
IDs from ID_LANGUAGE_FIRST
to ID_LANGUAGE_FIRST+MAX_LANGUAGES
will be used by Multilang Toolkit and should not be used for other purposes in your application.
5. Add menu item with ID_LANGUAGE_FIRST
to the application menu
6. Add the following line to the beginning of YourApplicationName.cpp
#include "MultiLang.h"
7. Call Multilang Library initialization after CWinApp::InitInstance()
in the InitInstance()
function in YourApplicationName.cpp
MultiLangInitLocalization(ID_LANGUAGE_FIRST, MAX_LANGUAGES, HKEY_CURRENT_USER, "Software/YourCompanyName/YourProductName", "GUILanguage");
Link MFC Extension DLL to Lingobit Localization Toolkit
1. On the Project menu, click YourProjectName Properties.
2. On the left pane, select Linker and then Input.
3. On the right pane, select Additional Dependencies.
4. Add path to multilang.lib to the Additional Dependencies
1. Add the following line to the beginning of YourDLLName.cpp
#include "MultiLang.h"
2. Add the following line between
if (!AfxInitExtensionModule(YourDLLNameDLL, hInstance)) return 0;
and
new CDynLinkLibrary(YourDLLNameDLL);
in DllMain
function in YourDllName.cpp
YourDLLNameDLL.hResource = MultiLangLoadLibrary(hInstance, HKEY_CURRENT_USER, "Software/YourCompanyName/YourProductName", "GUILanguage");
There are several ways to create resource-only DLLs.
To create a resource only DLL, follow these steps:
For more information, see the topics "resource-only DLLs" in MSDN help.
You can use Lingobit Localizer, innovative software localization tool, to simplify and speed-up creation of resource-only DLLs. Lingobit Localizer creates resource-only DLLs in three easy steps without any changes to the source code. Lingobit Localizer not only helps with creation of resource-only DLLs, but also assists in localizability testing, translation, QA checks and collaboration with translators. You can read about it at http://www.lingobit.com/tutorial/resourceonlydll/
2006-06-30
Multilingual Library 1.0
User Comments
No comments yet, sign in to comment.