Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 369
  • Last Modified:

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.
0
cheeonn
Asked:
cheeonn
  • 4
  • 3
  • 2
1 Solution
 
Le_RonCommented:
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
 
proskigCommented:
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
 
proskigCommented:
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.

 
cheeonnAuthor Commented:
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
 
proskigCommented:
proskig changed the proposed answer to a comment
0
 
Le_RonCommented:
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
 
cheeonnAuthor Commented:
Adjusted points from 20 to 25
0
 
cheeonnAuthor Commented:
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
 
cheeonnAuthor Commented:
Thank you very much. It has been great pleasure having you as a personal guidance.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now