Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing Globalization / Multilingual feature in win32 API application

I have developend a window application(Win32 API) in visual C++. I have to add multilingual feature in this application. Can any one Pls guide me how to get forward with this task.

like image 776
Ravi shankar Avatar asked Oct 31 '09 09:10

Ravi shankar


2 Answers

the basics for a multilingual application on Windows is the use of "resources". a resource is a chunk appended at the end of your executable, which only contains data, and is formatted in a very specific way in order for Windows to be able to interpret those data.

in your resources, you can find dialog boxes, string tables, but also version informations (those which are displayed in the properties dialog box of a file in the explorer). you can watch the resources of any dll or exe by opening the exe or dll in Visual C++. when developing an application, you can create a resource (File/New), add it to your project (the same as you when you add a file) and edit the resources (using the resource editor, generally a tab next to the File View in project explorer).

each resource (dialog, dialog, template, version info, string table, ...) contains a language identifier which you can change. you can create the same resource multiple times using different language identifier. once compiled, when the application is loaded by Windows, it will try to open resources which language are the closer to the Windows UI language.

a set of functions is defined in the Windows SDK to make good use of those resources: LoadString, LoadCursor, LoadBitmap, and everything in the resources chapter.

Now every time you use a string in your code, put it in a String Table resource and use the LoadString function to retrieve it. windows and dialog boxes are generally loaded in the correct language without needing any specific function call, as long as you have set the correct language identifier in the resources.

voila, that's the shortest introduction to multilingual development under Windows that i could do. i am sure that you can find a lot of well-written articles about resources or multilingual development under Windows on the net.

like image 88
Adrien Plisson Avatar answered Oct 22 '22 22:10

Adrien Plisson


There are several sides you have to worry about:

  1. Compile your application as Unicode
  2. localizing (translating) the application, making it "speak" another language
  3. use locale-aware behavior, where you have to sort, or format date/time/numbers as expected by the user

For localization the best current practice is to no use strings in your code, but store them in resource-only DLLs (or "satellite DLL") Probably best to start from here: http://msdn.microsoft.com/en-us/goglobal/bb978454.aspx, especially the tutorials and presentations on the right.

For the localization work down to detail, you can check this: http://mihai-nita.net/2007/05/03/how-to-localize-an-rc-file/

For locale-aware behavior you have to use special APIs like GetNumberFormat or GetDateFormat. You can probably start from here http://msdn.microsoft.com/en-us/library/dd319078%28VS.85%29.aspx or here http://msdn.microsoft.com/en-us/goglobal/dd565826.aspx

But of course no answer here will be enough, since there are full books on the topic. So just start from the MS globalization portal (http://msdn.microsoft.com/en-us/goglobal/), especially the "Learn" tab, and o from there.

And when you bump into some troubles (you most likely will), stop by at the microsoft.public.win32.programmer.international newsgroup (I know, taking someone away from stackoverflow might not be "good form", but there is a dedicated place, so you might get better answers).

like image 30
Mihai Nita Avatar answered Oct 22 '22 22:10

Mihai Nita