Adding multilanguage support to your application
Here is my way to change my App's language. It is tested under both Win98 and NT( Win95 will be good also). It looks good, but It needs more steps.
First, after you create you app, you should create a dll that contains all the resource of the application. the same resource ID but different language. The best way is add a new workspace of dll into your app's workspace, then drag and drop the resource. After doing that, modify the resource of the Dll to another language. This may take some time to do that.Complie and create the dll file.
In InitInstance( ) of your App class, before creating all windows or dialog, add code below:
(Japanese.dll is my resource dll file's name)
...
HINSTANCE hJapaneseDll //Global var
.....
CMultiLangApp::InitInstance()
{
......
//Get Language Setting from INI
uLanguage = GetProfileInt("Language", "Language",0);
if (uLanguage == 1)
{
//Language is set for Japanese.
hJapaneseDll = AfxLoadLibrary("Japanese.dll");
ASSERT(hJapaneseDll);
AfxSetResourceHandle(hJapaneseDll);
}
.....
//create dialog or main frame
.....
}
Last, add a switch such like menus or radios to change settings of language, then the next time run the app, it will display the language your expected.
The core is function AfxSetResourceHandle(HINSTANCE), which changes the location to find the resource. The common dialog is based on the version of Windows. So I think that if you wanna create a real business international application, you should read the Register in InitInstance( ) to get the version of windows, then change to the appropriate language. This way can support as many languages as your like.
Because I create this sample under Japanese windows. So the sample's language dll is japanese, I hope you can see it. The complier environment is VC6.0 SP3 ,WindowsNT 4.0 SP4 and Windows 98
Downloads
Comments
Debug Assertion Failed
Posted by Legacy on 11/12/2003 12:00amOriginally posted by: Md. Zahangir Alam
Hi,
I have a problem using MFC.
I have create some dll files and added them into my project.
After creating all things I have gotten such message.
My application juat like
CMyExtMapApp::InitInstance()
{
....
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
......
if (!ProcessShellCommand(cmdInfo))
return FALSE;
....
}
in this process 'ProcessShellCommand(cmdInfo)'
I have gotten message
"Debug assertion falied.
Program:...\MyExtMapApp.exe
File:docsingl.cpp
Line:215 "
How can I correct this? Any body can give some advice for this ?
Name: Zahangir Alam
Bangladesh
Very good, but I met another problem
Posted by Legacy on 09/07/2003 12:00amOriginally posted by: Xiaomin Yu
The method of load a resource dll to support multi-Lingual
application is very good. I have used this method to make a MDI app. to support Chinese(PRC) and English(US).
But I met another problem. I developed a dialog-based program and changed the type and size of all the dialog. when I excuted the program I fount that the font of different language app. is not the same. I changed the font in the dll and make them exactly the same. But when I excuted the program the font of two language is also not the same. What can I do?
Very good, but I met another problem
Posted by Legacy on 09/07/2003 12:00amOriginally posted by: Xiaomin Yu
The method of load a resource dll to support multi-Lingual
application is very good. I have used this method to make a MDI app. to support Chinese(PRC) and English(US).
But I met another problem. I developed a dialog-based program and changed the type and size of all the dialog. when I excuted the program I fount that the font of different language app. is not the same. I changed the font in the dll and make them exactly the same. But when I excuted the program the font of two language is also not the same. What can I do?
Can't see the Japanese in Visual C++
Posted by Legacy on 07/20/2003 12:00amOriginally posted by: Yuval
I tried to use the sample code , and when I choose the japanese version, I saw ?????????? instead of japanese (I installed the right language pack and I can see a japanese text properly on a word documnet). Beside of that when I'm trying to paste a japanese word into the Visual editor I also see ??????. I tried to ran the sample twice, once with _MBCS, and once with _UNICODE.
Thanks
Yuval.
Reply
a problem in MDI
Posted by Legacy on 08/19/2002 12:00amOriginally posted by: Juliet
I write a MDI application and want to do a dll to give a multilanguage support.The text of menu and dialog is changed.But if I open a new document,there will be a assert dialog.I traced and it always break at CDocManager::DoPromptFileName().Please help me.Thanks a lot.
ReplyHow to change standard dialog strings
Posted by Legacy on 08/30/1999 12:00amOriginally posted by: Joachim Friedhoff
How can i change the strings in the standard dialog boxes, like for file open, etc.
ReplyWorks with all resources...
Posted by Legacy on 07/05/1999 12:00amOriginally posted by: Tomaz Stih
My 5�. :-)
The AfxSetResourceHandle(HINSTANCE) changes the order in which MFC seeks for resources. This means that if you have same name for the same resource it will return the one that finds first.
ReplyThus this method will work with string tables just as well as with bitmaps and other resources. But even more - you can use this to override MFC resources.