Implement globalization / multilingualism in a Win32 API application

I got a windowed application (Win32 API) in Visual C ++. I have to add multilingual function to this application. Can anyone pls advise me how to move forward with this task.

+7
c ++ visual-c ++ winapi internationalization
source share
4 answers

The basics of a multilingual application on Windows is the use of "resources." a resource is a fragment added at the end of an executable file that contains only data and is formatted in a very specific way so that Windows can interpret this data.

in your resources you can find dialog boxes, string tables, as well as version information (those that appear in the file properties dialog box in Explorer). You can view the resources of any DLL or EXE by opening 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 when adding a file), and edit resources (using the resource editor, usually a tab next to the file view in the project explorer).

each resource (dialog, dialog, template, version information, table row, ...) contains a language identifier that you can change. You can create the same resource multiple times using a different language identifier. after compilation, when the application loads Windows, it will try to open resources whose language is closer to the language of the Windows user interface.

a set of functions is defined in the Windows SDK to efficiently use these resources: LoadString, LoadCursor, LoadBitmap and everything in the resources section.

Now every time you use a string in your code, put it in the String Table resource and use the LoadString function to get it. windows and dialog boxes are usually loaded in the correct language, without requiring any specific function call, if you set the correct language identifier in the resources.

voila, this is the shortest introduction to multilingual development under Windows that I could do. I'm sure you can find many well-written articles about resources or multilingual development for Windows on the web.

+5
source share

There are a few things you need to worry about:

  • Compile your application as Unicode
  • localization (translation) of the application, forcing him to "speak" in another language.
  • use language compatible behavior where you need to sort or format date / time / numbers as expected from the user

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

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

For behavior familiar with the language, you need to use special APIs such as GetNumberFormat or GetDateFormat. You can probably start 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, the answer here will not be enough, since there are complete books on this topic. So start with the MS globalization portal ( http://msdn.microsoft.com/en-us/goglobal/ ), especially the "Learn" tab and o from there.

And when you come across some problems (you most likely will), go to the microsoft.public.win32.programmer.international newsgroup (I know that grabbing someone from stackoverflow may not be β€œgood form”, but there is a dedicated place, so you can get better answers).

+2
source share

Use gettext for all of your lines.

0
source share

This can be a big problem or a small problem, depending on what your program does.

What to see:

  • String and character encoding. Putting strings into a resource (or using gettext) is the beginning, but you might think about how you store the strings inside; eg. look at Unicode encoding like UTF-16 if you are not already using that encoding.

  • Consider how you process and store string data, as it matters: do you need to sort or compare cases? ASCII order (for example, comparing a simple value in "char") may be incorrect. Listed below are some of these issues here .

  • The date and time output format, money output formats, and other things also depend on the culture.

  • Finally, you may need to reformat the user interface elements depending on which interface technology you are using. Lines are longer and shorter in different languages ​​with different system fonts. As a last resort, you may need to consider your layout for readers from right to left.

0
source share

All Articles