Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Multilingual project

Posted on 2000-04-26
Last Modified: 2012-05-04
I have finished a project recently. The User Interface is all in English. Then, on a last minute call, my boss asked me to do it in 2 languages.
How can I go about doing this?

Is it like, in the InitDialog, we load the labels to be converted to that particular language? I am not sure on how to get around to do this. Please show me a step by step method of handling this problem.

Thank you.
Question by:cheeonn
  • 4
  • 3
  • 2

Expert Comment

ID: 2750569
Hi cheeonn,
If you are working under Visual C++, that's quite simple: there is a string table in the resource where all strings used by your program are. By the way, you just have to translate that table.
If you are not, a solution is to have a header file containing the definition of all your strings.
#define ID_STRING1 "My first string"
#define ID_STRING2 "Another string"

Then, include this file in all classes needing them and use ID_STRING1 in place of "My first String" in your code. If you do this for every strings in your app, changing only the header file and re-compiling will give you the program in another language.

Hope this helps

Accepted Solution

proskig earned 25 total points
ID: 2750681
From codeguru:
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
      //Get Language Setting from INI
      uLanguage = GetProfileInt("Language", "Language",0);

      if (uLanguage == 1)
            //Language is set for Japanese.
            hJapaneseDll = AfxLoadLibrary("Japanese.dll");
      //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

Expert Comment

ID: 2750688
You might also want to check this comment
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 2754023
Err...in the String Table when I changed the language property to another language, some message about Code Page 950 comes out.
It means that I do not have the language installed?

Thank you for your solutions. I need more explanations on how to work on the solution.


Expert Comment

ID: 2754249
proskig changed the proposed answer to a comment

Expert Comment

ID: 2754571
Yes, that means a file is missing. Something may help you about that : open the READMEVC.HTM file in your visual studio root directory. Then, lokk after the title 'Multiple Language Resource Files'. Many things are explained there.

Once the corresponding .nls file is correctly installed on your machine, right-click on the 'string table' item in the resource tab and select 'insert copy'. You now have two string tables having their own language.

hope this helps

Author Comment

ID: 2771942
Adjusted points from 20 to 25

Author Comment

ID: 2771943
This is what I have done so far:
Create a new project.
W32 Dynamaic Link Library (Project Name: ChineseRes.dll). A simple dll project. Finish.

Then, I copied all these from my program(which is in English) files over to the ChineseRes.dll directory.
a. Res directory
b. All my bitmaps
c. Resource.h
d. Itss.rc

Then in my ChineseRes.dll project, I included the Itss.rc file. After that, I open up all the dialog boxes and change the interface to the language I desire, which is Chinese and save and compile the simple dll project.

After that, I copied the dll that has already been compiled to my Windows/System directory.

In my actual program(the existing one, which is in English), I did some alterations to the code, as in what "proskig" told me to do, which is:

I add an HINSTANCE member variable to the application's CWinApp derived class.

CWinApp::InitInstance definition:
ASSERT(m_hChineseResDLL !=NULL);

After that,
int CMyApp::ExitInstance()
  return CWinApp::ExitInstance();

OK, that is a bit long story there.

Anyway, there is just one big problem. How about the MessageBox? How do I change the language in the message box itself, since it is only found in the code not in the resource file or in the string table.

I tried this method, which is: I made another copy of my actual program, and I changed the UI one by one and entered all the text in the messagebox to the string table and replaced the AfxMessageBox("Just a message");
where 61447 is the value from the string table. Is that the correct way of doing?

And, how about the language from the
SetWindowsText? Can I use the same method as in the AfxMessageBox?
object.SetWindowsText(61447). But, this does not work.

Please help. Can you show me a correct way of doing this. The way I used is a little weird, isn't it?

Thank you.

If you do not understand what I have written here, I can be contacted at:

Please help. I have until somewhere third week of May to complete this assignment. I know, all these multilingual stuff takes a really really long time to complete.

Author Comment

ID: 2809404
Thank you very much. It has been great pleasure having you as a personal guidance.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
computer science syllabus 3 88
Meaning of "exceptions()" in "ist.exceptions( ist.exceptions() | ios_base:: badbit);" 3 80
c++, dynamic object by json 1 53
Outlook 13 41
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question