file locor_readme.htm

contents:



What is wxLocalisator?

It is a cpp-class for use with wxWindows.
It supports the internationalisation of your application.

Internationalisation with the free and portable GUI Toolkit wxWindows is quite easy because of the locale-concept and the great free tool poedit from Vaclav Slavik.

But your application has to decide which locale to choose and this is done via an entry in the configuration of your program (not very user-friendly) or with a dialog to ask the user.

The class wxLocalisator is such a dialog and it provides you additional features:

How do I use wxLocalisator?

You have to add the file locor.cpp to your sources, as this class is not part of the wxWindows distribution. Include the file locor.h in your main application file, like shown in the demo.

By calling AskUser() the dialog will show up and you get a locale-ID as return-value. The choosen locale will be stored in ./locale/locale.ini, which is the default ini-file of wxLocalisator.
Just set this ID in the global locale-object.
If wxLocalisator can read a valid locale from its ini-file, the dialog will not be shown, unless you call AskUser(true).
(The name of this method is not just ShowModal() because of its side effects.)

Customisation

The method AskUser() provides an additional parameter style to choose from three styles: The method ItemsShown() lets you choose from three possible layouts:
The corresponding flag for each language is shown or the name of the language or both (default).
The socond parameter decides whether the short descriptive text is shown (default) or not.

If you choose the third style, the mode parameter of AskUser() and and a former call of SetStyle() have obviously no effect.
You can change the shown file by calling SetFileHtml().
If you choose the second style and you want the generated html-code to look more fancy, you have to edit the generating code in the method wxLocalisator::BuildHtml().

By default no language is known by the dialog.
Add a language by a call of AddLanguage().
You can also read all languages specified in the ini-file by calling ReadFile(), which simply makes some calls of AddLanguage().

Have a look at the demo i18ner.cpp, which shows the different possibilities.

What about the files locorh.cpp and locorh.h?

There is a light-weight-version of the class, named wxLocalisatorHtml. It resides in these files.
This class can only show up a static html-file, and it does not store anything in an ini-file.
The default file is ./locale/locale.htm, like above, but no ini-file is needed.
You are responsible for storing the locale by yourself.
The method AskUser() now has a wxString as return-value, giving the ascii-code of the locale (like "en_GB" or "de_DE").
Use the method FindId() to translate it to the needed locale-ID.
Have a look at the demo i18ner_h.cpp.

Download

Download the zip-archive with the code of the dialogs, the code of the demos and a VC++ project file.

Legal stuff

This code is a contribution to wxWindows and underlies (only) the same small restrictions.
You may use and modificate it freely.

As the author of this code I do not guarantee anything, so do not blame me for any damage it may cause or something else.

Any suggestions are welcome.

Peter Lenhard, January 2003

(Homepage: www.peter-lenhard.de)
(Email: pl@peter-lenhard.de)