]> git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/internationalization.h
f2410f85e3247f1fce8832d9bda9c33b6d6ac2ae
[wxWidgets.git] / docs / doxygen / overviews / internationalization.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: internationalization.h
3 // Purpose: topic overview
4 // Author: wxWidgets team
5 // RCS-ID: $Id$
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 /**
10
11 @page overview_i18n Internationalization
12
13 @tableofcontents
14
15 Although internationalization of an application (i18n for short) involves far
16 more than just translating its text messages to another message - date, time
17 and currency formats need changing too, some languages are written left to
18 right and others right to left, character encoding may differ and many other
19 things may need changing too - it is a necessary first step. wxWidgets provides
20 facilities for message translation with its wxLocale class and is itself fully
21 translated into several languages. Please consult wxWidgets home page for the
22 most up-to-date translations - and if you translate it into one of the
23 languages not done yet, your translations would be gratefully accepted for
24 inclusion into future versions of the library!
25
26 The wxWidgets approach to i18n closely follows the GNU gettext package.
27 wxWidgets uses the message catalogs which are binary compatible with gettext
28 catalogs and this allows to use all of the programs in this package to work
29 with them. But note that no additional libraries are needed during run-time,
30 however, so you have only the message catalogs to distribute and nothing else.
31
32 During program development you will need the gettext package for working with
33 message catalogs. @b Warning: gettext versions @< 0.10 are known to be buggy,
34 so you should find a later version of it!
35
36 There are two kinds of message catalogs: source catalogs which are text files
37 with extension .po and binary catalogs which are created from the source ones
38 with @e msgfmt program (part of gettext package) and have the extension .mo.
39 Only the binary files are needed during program execution.
40
41 Translating your application involves several steps:
42
43 @li Translating the strings in the program text using wxGetTranslation or
44 equivalently the @c _() macro.
45 @li Extracting the strings to be translated from the program: this uses the
46 work done in the previous step because @c xgettext program used for string
47 extraction recognises the standard @c _() as well as (using its @c -k
48 option) our wxGetTranslation and extracts all strings inside the calls to
49 these functions. Alternatively, you may use @c -a option to extract all the
50 strings, but it will usually result in many strings being found which don't
51 have to be translated at all. This will create a text message catalog - a
52 .po file.
53 @li Translating the strings extracted in the previous step to other
54 language(s). It involves editing the .po file.
55 @li Compiling the .po file into .mo file to be used by the program.
56 @li Installing the .mo files with your application in the appropriate location
57 for the target system (@see overview_i18n_mofiles).
58 @li Setting the appropriate locale in your program to use the strings for the
59 given language: see wxLocale.
60
61
62 @section overview_i18n_mofiles Installing translation catalogs
63
64 The .mo files with compiled catalogs must be included with the application.
65 By default, wxFileTranslationsLoader is used to load them from files installed
66 alongside the application (although you could use wxResourceTranslationsLoader
67 or some custom loader too).
68
69 The files are expected to be in the resources directory (as returned by
70 wxStandardPaths::GetLocalizedResourcesDir(wxStandardPaths::ResourceCat_Messages).
71 If the message catalogs are not installed in this default location you may
72 explicitly use wxFileTranslationsLoader::AddCatalogLookupPathPrefix() to still
73 allow wxWidgets to find them, but it is recommended to use the default
74 locations when possible.
75
76 Depending on the platform, the default location differs. On Windows, it is
77 alongside the executable. On Unix, translations are expected to be in
78 "$prefix/share/locale". On OS X, application bundle's @em Resources subdirectory
79 is used.
80
81 In all cases, translations are searched for in subdirectories named using the
82 languages codes from ISO 639. The .mo file(s) should be located either directly
83 in that directory or in LC_MESSAGES subdirectory. On OS X, ".lproj" extension
84 is used for the per-languages Resources subdirectories.
85
86 Here's how an app would typically install the files on Unix:
87 @code
88 /usr/bin/myapp
89 /usr/share/locale/de/LC_MESSAGES/myapp.mo
90 /usr/share/locale/fr/LC_MESSAGES/myapp.mo
91 @endcode
92 And on OS X:
93 @code
94 MyApp.app/Contents/MacOS/MyApp
95 MyApp.app/Contents/Resources/de.lproj/myapp.mo
96 MyApp.app/Contents/Resources/fr.lproj/myapp.mo
97 @endcode
98 And on Windows:
99 @code
100 C:\Program Files\MyApp\myapp.exe
101 C:\Program Files\MyApp\de\myapp.mo
102 C:\Program Files\MyApp\fr\myapp.mo
103 @endcode
104 It is of course possible to use the Unix layout everywhere instead.
105
106
107 @section overview_i18n_menuaccel Translating Menu Accelerators
108
109 If you translate the accelerator modifier names (Ctrl, Alt and Shift) in your
110 menu labels, you may find the accelerators no longer work. In your message
111 catalogs, you need to provide individual translations of these modifiers from
112 their lower case names (ctrl, alt, shift) so that the wxWidgets accelerator
113 code can recognise them even when translated. wxWidgets does not provide
114 translations for all of these currently. wxWidgets does not yet handle
115 translated special key names such as Backspace, End, Insert, etc.
116
117
118 @see
119 @li The gettext Manual: http://www.gnu.org/software/gettext/manual/gettext.html
120 @li @ref overview_nonenglish - It focuses on handling charsets related problems.
121 @li @ref page_samples_internat - Shows you how all this looks in practice.
122
123 */