dcsimg

Adding multilanguage support to your application

WEBINAR:
On-Demand

Desktop-as-a-Service Designed for Any Cloud ? Nutanix Frame


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



This article was originally published on July 3rd, 1999

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date