Adding multilanguage support to your application

Environment:VC6 SP3, NT4 SP4, Win98

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.

The second is Modify you app source code.

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

Download demo project - 74 KB



Comments

  • Debug Assertion Failed

    Posted by Legacy on 11/12/2003 12:00am

    Originally 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

    Reply
  • Very good, but I met another problem

    Posted by Legacy on 09/07/2003 12:00am

    Originally 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?

    Reply
  • Very good, but I met another problem

    Posted by Legacy on 09/07/2003 12:00am

    Originally 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?

    Reply
  • Can't see the Japanese in Visual C++

    Posted by Legacy on 07/20/2003 12:00am

    Originally 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:00am

    Originally 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.

    Reply
  • How to change standard dialog strings

    Posted by Legacy on 08/30/1999 12:00am

    Originally posted by: Joachim Friedhoff

    How can i change the strings in the standard dialog boxes, like for file open, etc.

    Reply
  • Works with all resources...

    Posted by Legacy on 07/05/1999 12:00am

    Originally 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.
    Thus 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.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: September 10, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild". This loop of continuous delivery and continuous feedback is …

  • Java developers know that testing code changes can be a huge pain, and waiting for an application to redeploy after a code fix can take an eternity. Wouldn't it be great if you could see your code changes immediately, fine-tune, debug, explore and deploy code without waiting for ages? In this white paper, find out how that's possible with a Java plugin that drastically changes the way you develop, test and run Java applications. Discover the advantages of this plugin, and the changes you can expect to see …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds