Demonstrates how to support multiple languages in a single XLL
This add-in demonstrates how to support multiple languages in a single XLL, using a resource file. The add-in will use the language that best matches the user's current regional settings, as set in the Control Panel.
For step-by-step instructions on how to convert an existing project to support multiple languages, see Conversion of an existing project in the User Guide.
For a sample that allows the language to be changed dynamically, see Dynamic localized (Single DLL) sample.
Depending on which language is being used, various features of the add-in will appear differently:
Feature | English | French |
---|---|---|
Menu texts |
|
|
Toolbar bitmaps and texts |
|
|
Error messages |
|
|
Excel Formula Wizard |
|
|
Message box |
|
|
The resource file InterSingle.rc contains two string tables, one in English (US) and one in French (France). It also contains two bitmaps, one for each language.
To localize run-time error messages, the french error message file
xlpresfrfr.rc
is included along with the standard english
file xlpres.rc
.
In contrast to a standard XLL, this one uses resource IDs such as #202 instead of strings wherever possible. These IDs represent strings held in the resource file. The XLL+ run-time libraries take care of loading the correct language version of the string.
Resource IDs should be used in the following places:
/* static */ LPCTSTR CInterSingleApp::m_pszDefName = _T("#1");
m_menu.SetTexts(_T("#2")); m_menu.AddItem(_T("#3"), "BuyWater");
// Create toolbar CXlToolbar::AddToolbar(m_pszToolbarName); CXlToolbar::AddTool(m_pszToolbarName, 1, _T("BuyWater"), _T("#5")); CXlToolbar::SetToolBitmap(m_pszToolbarName, 1, IDB_BITMAP1); CXlToolbar::ShowToolbar(m_pszToolbarName, true, CXlToolbar::DockRight);
CXllApp::XlMessageBox(XllGetTranslatedString("#0x0005"),
XlMessageBoxTypeExclamation);
(Notice that this string uses a hexadecimal string ID, prefixed with "0x", instead
of a decimal ID. Either form can be used at any time.)
Before opening the add-in, use the Control Panel's Regional settings applet to set the current language to English or French.
Open the add-in, and note that all the following are localized:
Close Excel.
Return to the Regional settings applet, and change to French or English.
Open Excel again, and open the add-in. Note that all the features listed above are now in a different language.
Each sample project is located in a sub-directory of the Samples directory of the XLL+ installation. To use the sample project, open the solution file InterSingle.sln or the project file InterSingle.vcproj.
You can enable debugging under Excel by using the Setup Debugging command in the XLL+ ToolWindow.
When delivered, the help files are excluded from the build.
You can enable the help build by selecting the files
InterSingle.help.xml
and
InterSingle.chm
in the Solution Explorer,
and using the right-click menu to view Properties.
Select the page "Configuration Properties/General" and
set the "Excluded from build" property to "No".
See Generating help
in the User Guide for more information.
List of Sample Projects | Conversion of an existing project | Localized (Multiple DLLs) sample | Dynamic localized (Single DLLs) sample