?
Solved

Multilingual project

Posted on 2000-04-26
9
Medium Priority
?
364 Views
Last Modified: 2012-05-04
Hello,
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.
0
Comment
Question by:cheeonn
[X]
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
  • 4
  • 3
  • 2
9 Comments
 

Expert Comment

by:Le_Ron
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.
E.g.:
#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
0
 
LVL 5

Accepted Solution

by:
proskig earned 75 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
......
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
0
 
LVL 5

Expert Comment

by:proskig
ID: 2750688
You might also want to check this comment
http://codeguru.developer.com/mfc/comments/7038.shtml
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:cheeonn
ID: 2754023
Hello,
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.

0
 
LVL 5

Expert Comment

by:proskig
ID: 2754249
proskig changed the proposed answer to a comment
0
 

Expert Comment

by:Le_Ron
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
0
 

Author Comment

by:cheeonn
ID: 2771942
Adjusted points from 20 to 25
0
 

Author Comment

by:cheeonn
ID: 2771943
Hello,
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.
HINSTANCE m_hChineseResDLL;

Then,
CWinApp::InitInstance definition:
m_hChineseResDLL=LoadLibrary("ChineseRes.dll");
ASSERT(m_hChineseResDLL !=NULL);
AfxSetResourceHandle(m_hChineseResDLL);

After that,
int CMyApp::ExitInstance()
{
  FreeLibrary(m_hChineseResDLL);
  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");
to
AfxMessageBox(61447);
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:
cheeonn@yahoo.com

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

Author Comment

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

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.
Suggested Courses

762 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