Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Internationalization in MFC

It's finally (after years of postponing) the time to localize my app in a few other languages other than English.

The first challenge is to design the integration into my C++ / MFC application that has dozens of dialogs and countless strings. I came across two possible alternative implementations:

  1. Compile and deploy localized resource files as DLLs
  2. Extract and replace all strings with the localized version. For each language there will be an XML (or simple text) file.

Personally I opt for the second alternative since it seems to me more flexible. The changes are many but not hard to make, and very importantly the XML files will be very easy to modify for the translators.

Any advise is greatly appreciated.

Regards,
Cosmin Unguru
http://www.batchphoto.com/

like image 586
Cosmin Avatar asked Dec 09 '10 12:12

Cosmin


2 Answers

I did some long-living MFC projects with different languages. I strongly recommend the first approach with resource-only DLLs.

The reasons:

(1) If the user does a XCOPY install, he always has the default language (English) in the main executables.

(2) If you don't translate everything (e.g. you're late with your release or forget some strings), the Windows resource functions if properly used return the resource in the default language automatically - you don't have to implement it on your own.

(3) My very person opinion: (a) Line breaks, tabs, whitespaces in XML files are a pain in your a**. (b) Merging XML files is even worse...

(4) Don't forget the encoding. It's okay in XML but your translators might use an unsuitable editor and damage the file.

And now for the main reason:

(5) You will have to rearrange many of your dialogs, because many strings are longer in e.g. French or German than in English. And making all statics, buttons, ... larger "just in case" looks crappy.

Another hint: Spend some bucks and buy one of the translation tools which import your projects / binaries and build up a translation database. This will be amortized after the first release.

Another hint (2): If possible make a release which doesn't contain any changes but only the multi-language feature. Also in future, if possible: Release your product in English. Then do the translation in one single step (per language) and release the other languages.

like image 166
ur. Avatar answered Sep 20 '22 03:09

ur.


My good and friendly suggestion from somebody who worked a lot with localization:

  1. Grab GNU Gettext,
  2. Mark all your strings as _("English").
  3. Extract all strings using gettext tool xgettext and compile dictionalries
  4. Translate string using great tools like poedit.
  5. Use gettext in your project and make your localization life simpler!

You can also use boost::locale for same purpose - it uses GNU Gettext dictionaries and approach but provides different and more powerful runtime and for windows developer it has very good addon - it supports wide strings that MFC requires to use for normal Unicode support.

Don't use resources and other "translation" tools that are total crap from linguistic point of view (and developer's point of view as well).

Further reading: http://cppcms.sourceforge.net/boost_locale/html/tutorial.html

like image 42
Artyom Avatar answered Sep 17 '22 03:09

Artyom