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.
views:
346answers:
4the 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.
no 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.
This can be a big problem, or a small problem, depending on what your program does.
Things to look into:
String and character encoding. Putting strings into a resource (or using gettext) is a start, but you may want to consider how you store strings internally; eg. look into a Unicode encoding like UTF-16 if you aren't using such an encoding already.
Consider how you process and store string data, as it matters as well: do you need to sort or do case comparisons? ASCII order (eg comparing the simple value in a 'char') might not be right. Some of these concerns are outlined here.
Date and time output formats, money output formats, and other things depend on culture as well.
Finally, it's possible that you may need to re-layout your UI elements depending on what interface technology you are using. Strings are longer and shorter in different laguages with different system fonts. In the extreme case, you may need to consider your layout for right-to-left readers.
There are several sides you have to worry about:
- Compile your application as Unicode
- localizing (translating) the application, making it "speak" another language
- 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 use 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://www.mihai-nita.net/article.php?artID=20070503a
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).