1999-02-26 20:43:43 -05:00
|
|
|
\section{Internationalization}\label{internationalization}
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
Although internationalization of an application (i18n for short) involves far
|
2005-02-11 15:08:51 -05:00
|
|
|
more than just translating its text messages to another message - date, time and
|
1999-02-26 20:43:43 -05:00
|
|
|
currency formats need changing too, some languages are written left to right
|
|
|
|
and others right to left, character encoding may differ and many other things
|
2005-02-11 15:08:51 -05:00
|
|
|
may need changing too - it is a necessary first step. wxWidgets provides
|
2000-07-15 15:51:35 -04:00
|
|
|
facilities for message translation with its
|
1999-02-26 20:43:43 -05:00
|
|
|
\helpref{wxLocale}{wxlocale} class and is itself fully translated into several
|
2004-05-04 04:27:20 -04:00
|
|
|
languages. Please consult wxWidgets home page for the most up-to-date
|
1999-02-28 15:59:08 -05:00
|
|
|
translations - and if you translate it into one of the languages not done
|
2005-04-08 10:34:30 -04:00
|
|
|
yet, your translations would be gratefully accepted for inclusion into future
|
|
|
|
versions of the library!
|
1999-02-26 20:43:43 -05:00
|
|
|
|
2005-04-08 10:34:30 -04:00
|
|
|
The wxWidgets approach to i18n closely follows the GNU gettext package. wxWidgets uses the
|
1999-02-26 20:43:43 -05:00
|
|
|
message catalogs which are binary compatible with gettext catalogs and this
|
|
|
|
allows to use all of the programs in this package to work with them. But note
|
2005-04-08 10:34:30 -04:00
|
|
|
that no additional libraries are needed during run-time, however, so you
|
1999-02-26 20:43:43 -05:00
|
|
|
have only the message catalogs to distribute and nothing else.
|
|
|
|
|
1999-02-28 15:59:08 -05:00
|
|
|
During program development you will need the gettext package for
|
1999-02-26 20:43:43 -05:00
|
|
|
working with message catalogs. {\bf Warning:} gettext versions < 0.10 are known
|
|
|
|
to be buggy, so you should find a later version of it!
|
|
|
|
|
|
|
|
There are two kinds of message catalogs: source catalogs which are text files
|
|
|
|
with extension .po and binary catalogs which are created from the source ones
|
2000-07-15 15:51:35 -04:00
|
|
|
with {\it msgfmt} program (part of gettext package) and have the extension .mo.
|
1999-02-26 20:43:43 -05:00
|
|
|
Only the binary files are needed during program execution.
|
|
|
|
|
|
|
|
The program i18n involves several steps:
|
|
|
|
|
|
|
|
\begin{enumerate}\itemsep=0pt
|
|
|
|
\item Translating the strings in the program text using
|
2003-01-25 17:49:41 -05:00
|
|
|
\helpref{wxGetTranslation}{wxgettranslation} or equivalently the
|
2004-06-23 16:31:23 -04:00
|
|
|
\helpref{\_()}{underscore} macro.
|
1999-02-26 20:43:43 -05:00
|
|
|
\item Extracting the strings to be translated from the program: this uses the
|
2003-01-25 17:49:41 -05:00
|
|
|
work done in the previous step because {\tt xgettext} program used for string
|
|
|
|
extraction recognises the standard \_() as well as (using its {\tt -k} option)
|
|
|
|
our wxGetTranslation and extracts all strings inside the calls to these
|
|
|
|
functions. Alternatively, you may use {\tt -a} option to extract all the
|
|
|
|
strings, but it will usually result in many strings being found which don't
|
2005-02-11 15:08:51 -05:00
|
|
|
have to be translated at all. This will create a text message catalog - a .po
|
2003-01-25 17:49:41 -05:00
|
|
|
file.
|
1999-02-26 20:43:43 -05:00
|
|
|
\item Translating the strings extracted in the previous step to other
|
|
|
|
language(s). It involves editing the .po file.
|
|
|
|
\item Compiling the .po file into .mo file to be used by the program.
|
|
|
|
\item Setting the appropriate locale in your program to use the strings for the
|
|
|
|
given language: see \helpref{wxLocale}{wxlocale}.
|
|
|
|
\end{enumerate}
|
|
|
|
|
2004-12-25 10:04:30 -05:00
|
|
|
If you want your app to run under MacOS X with internationlization as
|
|
|
|
described above you'll need to make one modification to the Info.plist
|
|
|
|
file which describes the contents of the "application bundle". This
|
|
|
|
file (an XML text file in UTF-8 format) should have a
|
|
|
|
CFBundleDevelopmentRegion entry describing the language of the developer
|
|
|
|
- mostly English - and normally MacOS X will query the bundle for the
|
|
|
|
presence of certain resource directories to find out which languages
|
|
|
|
are supported (e.g. the directory German.lproj for German).
|
|
|
|
Since wxWidgets based applications don't use these directories
|
|
|
|
for storing resource information (they store the translation in the
|
|
|
|
mo files instead) the application needs to be told explicitly which
|
|
|
|
langauges are supported. This is done by adding a CFBundleLocalizations
|
|
|
|
entry to Info.plist. This can look like this:
|
|
|
|
|
|
|
|
\begin{verbatim}
|
|
|
|
<key>CFBundleDevelopmentRegion</key>
|
|
|
|
<string>English</string>
|
|
|
|
<key>CFBundleLocalizations</key>
|
|
|
|
<array>
|
|
|
|
<string>en</string>
|
|
|
|
<string>de</string>
|
|
|
|
<string>fr</string>
|
|
|
|
</array>
|
|
|
|
\end{verbatim}
|
|
|
|
|
1999-02-28 15:59:08 -05:00
|
|
|
See also the GNU gettext documentation linked from {\tt docs/html/index.htm} in
|
2004-05-04 04:27:20 -04:00
|
|
|
your wxWidgets distribution.
|
1999-02-28 15:59:08 -05:00
|
|
|
|
2000-03-18 04:20:21 -05:00
|
|
|
See also \helpref{Writing non-English applications}{nonenglishoverview}.
|
2000-01-19 18:07:23 -05:00
|
|
|
It focuses on handling charsets related problems.
|
|
|
|
|
2002-08-20 09:41:45 -04:00
|
|
|
Finally, take a look at the \helpref{i18n sample}{sampleinternat} which shows
|
2005-04-08 10:34:30 -04:00
|
|
|
you how all this looks in practice.
|
2002-08-20 09:41:45 -04:00
|
|
|
|
2006-03-24 07:13:07 -05:00
|
|
|
\wxheading{Translating menu accelerators}
|
|
|
|
|
|
|
|
If you translate the accelerator modifier names (Ctrl, Alt and Shift) in your menu labels, you may find
|
|
|
|
the accelerators no longer work. In your message catalogs, you need to provide individual translations
|
|
|
|
of these modifiers from their lower case names (ctrl, alt, shift) so that the wxWidgets accelerator
|
|
|
|
code can recognise them even when translated. wxWidgets does not provide translations for all of these
|
|
|
|
currently. wxWidgets does not yet handle translated special key names such as Backspace,
|
|
|
|
End, Insert, etc.
|
|
|
|
|