]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/ti18n.tex
Spacing tweak
[wxWidgets.git] / docs / latex / wx / ti18n.tex
... / ...
CommitLineData
1\section{Internationalization}\label{internationalization}
2
3Although internationalization of an application (i18n for short) involves far
4more than just translating its text messages to another message - date, time and
5currency formats need changing too, some languages are written left to right
6and others right to left, character encoding may differ and many other things
7may need changing too - it is a necessary first step. wxWidgets provides
8facilities for message translation with its
9\helpref{wxLocale}{wxlocale} class and is itself fully translated into several
10languages. Please consult wxWidgets home page for the most up-to-date
11translations - and if you translate it into one of the languages not done
12yet, your translations would be gratefully accepted for inclusion into future
13versions of the library!
14
15The wxWidgets approach to i18n closely follows the GNU gettext package. wxWidgets uses the
16message catalogs which are binary compatible with gettext catalogs and this
17allows to use all of the programs in this package to work with them. But note
18that no additional libraries are needed during run-time, however, so you
19have only the message catalogs to distribute and nothing else.
20
21During program development you will need the gettext package for
22working with message catalogs. {\bf Warning:} gettext versions < 0.10 are known
23to be buggy, so you should find a later version of it!
24
25There are two kinds of message catalogs: source catalogs which are text files
26with extension .po and binary catalogs which are created from the source ones
27with {\it msgfmt} program (part of gettext package) and have the extension .mo.
28Only the binary files are needed during program execution.
29
30The program i18n involves several steps:
31
32\begin{enumerate}\itemsep=0pt
33\item Translating the strings in the program text using
34\helpref{wxGetTranslation}{wxgettranslation} or equivalently the
35\helpref{\_()}{underscore} macro.
36\item Extracting the strings to be translated from the program: this uses the
37work done in the previous step because {\tt xgettext} program used for string
38extraction recognises the standard \_() as well as (using its {\tt -k} option)
39our wxGetTranslation and extracts all strings inside the calls to these
40functions. Alternatively, you may use {\tt -a} option to extract all the
41strings, but it will usually result in many strings being found which don't
42have to be translated at all. This will create a text message catalog - a .po
43file.
44\item Translating the strings extracted in the previous step to other
45language(s). It involves editing the .po file.
46\item Compiling the .po file into .mo file to be used by the program.
47\item Installing the .mo files with your application in the appropriate
48location for the target system which is the one returned by
49\helpref{wxStandardPaths::GetLocalizedResourcesDir(wxStandardPaths::ResourceCat\_Messages)}{wxstandardpathsgetlocalizedresourcesdir}.
50If the message catalogs are not installed in this default location you may
51explicitly use \helpref{AddCatalogLookupPathPrefix()}{wxlocaleaddcataloglookuppathprefix} to
52still allow wxWidgets to find them but it is strongly recommended to use the
53default directory.
54\item Setting the appropriate locale in your program to use the strings for the
55given language: see \helpref{wxLocale}{wxlocale}.
56\end{enumerate}
57
58See also the GNU gettext documentation linked from {\tt docs/html/index.htm} in
59your wxWidgets distribution.
60
61See also \helpref{Writing non-English applications}{nonenglishoverview}.
62It focuses on handling charsets related problems.
63
64Finally, take a look at the \helpref{i18n sample}{sampleinternat} which shows
65you how all this looks in practice.
66
67\wxheading{Translating menu accelerators}
68
69If you translate the accelerator modifier names (Ctrl, Alt and Shift) in your menu labels, you may find
70the accelerators no longer work. In your message catalogs, you need to provide individual translations
71of these modifiers from their lower case names (ctrl, alt, shift) so that the wxWidgets accelerator
72code can recognise them even when translated. wxWidgets does not provide translations for all of these
73currently. wxWidgets does not yet handle translated special key names such as Backspace,
74End, Insert, etc.
75