Link to home
Start Free TrialLog in
Avatar of cheeonn
cheeonn

asked on

Multilingual project

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.
Avatar of Le_Ron
Le_Ron

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
ASKER CERTIFIED SOLUTION
Avatar of proskig
proskig

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You might also want to check this comment
http://codeguru.developer.com/mfc/comments/7038.shtml
Avatar of cheeonn

ASKER

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.

proskig changed the proposed answer to a comment
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
Avatar of cheeonn

ASKER

Adjusted points from 20 to 25
Avatar of cheeonn

ASKER

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.
Avatar of cheeonn

ASKER

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