]> git.saurik.com Git - wxWidgets.git/blame - docs/doxygen/overviews/nonenglish.h
added Id keyword
[wxWidgets.git] / docs / doxygen / overviews / nonenglish.h
CommitLineData
15b6757b
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: nonenglish
3// Purpose: topic overview
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/*!
36c9828f 10
15b6757b 11 @page nonenglish_overview Writing non-English applications
36c9828f 12
15b6757b
FM
13 This article describes how to write applications that communicate with
14 the user in a language other than English. Unfortunately many languages use
15 different charsets under Unix and Windows (and other platforms, to make
16 the situation even more complicated). These charsets usually differ in so
17 many characters that it is impossible to use the same texts under all
18 platforms.
19 The wxWidgets library provides a mechanism that helps you avoid distributing many
36c9828f 20 identical, only differently encoded, packages with your application
15b6757b 21 (e.g. help files and menu items in iso8859-13 and windows-1257). Thanks
36c9828f 22 to this mechanism you can, for example, distribute only iso8859-13 data
15b6757b
FM
23 and it will be handled transparently under all systems.
24 Please read #Internationalization which
25 describes the locales concept.
26 In the following text, wherever @e iso8859-2 and @e windows-1250 are
27 used, any encodings are meant and any encodings may be substituted there.
28 @b Locales
29 The best way to ensure correctly displayed texts in a GUI across platforms
36c9828f
FM
30 is to use locales. Write your in-code messages in English or without
31 diacritics and put real messages into the message catalog (see
15b6757b
FM
32 #Internationalization).
33 A standard .po file begins with a header like this:
36c9828f 34
15b6757b
FM
35 @code
36 # SOME DESCRIPTIVE TITLE.
37 # Copyright (C) YEAR Free Software Foundation, Inc.
38 # FIRST AUTHOR EMAIL@ADDRESS, YEAR.
39 #
40 msgid ""
41 msgstr ""
42 "Project-Id-Version: PACKAGE VERSION\n"
43 "POT-Creation-Date: 1999-02-19 16:03+0100\n"
44 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
45 "Last-Translator: FULL NAME EMAIL@ADDRESS\n"
46 "Language-Team: LANGUAGE LL@li.org\n"
47 "MIME-Version: 1.0\n"
48 "Content-Type: text/plain; charset=CHARSET\n"
49 "Content-Transfer-Encoding: ENCODING\n"
50 @endcode
36c9828f 51
15b6757b 52 Note this particular line:
36c9828f 53
15b6757b
FM
54 @code
55 "Content-Type: text/plain; charset=CHARSET\n"
56 @endcode
36c9828f 57
15b6757b
FM
58 It specifies the charset used by the catalog. All strings in the catalog
59 are encoded using this charset.
60 You have to fill in proper charset information. Your .po file may look like this
36c9828f
FM
61 after doing so:
62
15b6757b
FM
63 @code
64 # SOME DESCRIPTIVE TITLE.
65 # Copyright (C) YEAR Free Software Foundation, Inc.
66 # FIRST AUTHOR EMAIL@ADDRESS, YEAR.
67 #
68 msgid ""
69 msgstr ""
70 "Project-Id-Version: PACKAGE VERSION\n"
71 "POT-Creation-Date: 1999-02-19 16:03+0100\n"
72 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
73 "Last-Translator: FULL NAME EMAIL@ADDRESS\n"
74 "Language-Team: LANGUAGE LL@li.org\n"
75 "MIME-Version: 1.0\n"
76 "Content-Type: text/plain; charset=iso8859-2\n"
77 "Content-Transfer-Encoding: 8bit\n"
78 @endcode
36c9828f 79
15b6757b
FM
80 (Make sure that the header is @b not marked as @e fuzzy.)
81 wxWidgets is able to use this catalog under any supported platform
82 (although iso8859-2 is a Unix encoding and is normally not understood by
83 Windows).
84 How is this done? When you tell the wxLocale class to load a message catalog that
85 contains a correct header, it checks the charset. The catalog is then converted
86 to the charset used (see
87 wxLocale::GetSystemEncoding and
88 wxLocale::GetSystemEncodingName) by
89 the user's operating system. This is the default behaviour of the
90 #wxLocale class; you can disable it by @b not passing
91 @c wxLOCALE_CONV_ENCODING to wxLocale::Init.
92 @b Non-English strings or 8-bit characters in the source code
93 By convention, you should only use characters without diacritics (i.e. 7-bit
94 ASCII strings) for msgids in the source code and write them in English.
95 If you port software to wxWindows, you may be confronted with legacy source
96 code containing non-English string literals. Instead of translating the strings
97 in the source code to English and putting the original strings into message
98 catalog, you may configure wxWidgets to use non-English msgids and translate to
99 English using message catalogs:
36c9828f
FM
100
101
15b6757b
FM
102 If you use the program @c xgettext to extract the strings from
103 the source code, specify the option @c --from-code=source code charset.
104 Specify the source code language and charset as arguments to
105 wxLocale::AddCatalog. For example:
36c9828f 106
15b6757b
FM
107 @code
108 locale.AddCatalog(_T("myapp"),
109 wxLANGUAGE_GERMAN, _T("iso-8859-1"));
110 @endcode
36c9828f
FM
111
112
113
114
15b6757b 115 @b Font mapping
36c9828f 116 You can use @ref mbconvclasses_overview and
15b6757b 117 #wxFontMapper to display text:
36c9828f 118
15b6757b
FM
119 @code
120 if (!wxFontMapper::Get()-IsEncodingAvailable(enc, facename))
121 {
122 wxFontEncoding alternative;
123 if (wxFontMapper::Get()-GetAltForEncoding(enc, ,
124 facename, @false))
125 {
126 wxCSConv convFrom(wxFontMapper::Get()-GetEncodingName(enc));
127 wxCSConv convTo(wxFontMapper::Get()-GetEncodingName(alternative));
128 text = wxString(text.mb_str(convFrom), convTo);
129 }
130 else
131 ...failure (or we may try iso8859-1/7bit ASCII)...
132 }
133 ...display text...
134 @endcode
36c9828f 135
15b6757b
FM
136 @b Converting data
137 You may want to store all program data (created documents etc.) in
138 the same encoding, let's say @c utf-8. You can use
139 #wxCSConv class to convert data to the encoding used by the
140 system your application is running on (see
141 wxLocale::GetSystemEncoding).
142 @b Help files
143 If you're using #wxHtmlHelpController there is
144 no problem at all. You only need to make sure that all the HTML files contain
145 the META tag, e.g.
36c9828f 146
15b6757b
FM
147 @code
148 meta http-equiv="Content-Type" content="text/html; charset=iso8859-2"
149 @endcode
36c9828f 150
15b6757b
FM
151 and that the hhp project file contains one additional line in the @c OPTIONS
152 section:
36c9828f 153
15b6757b
FM
154 @code
155 Charset=iso8859-2
156 @endcode
36c9828f 157
15b6757b
FM
158 This additional entry tells the HTML help controller what encoding is used
159 in contents and index tables.
36c9828f 160
15b6757b 161 */
36c9828f
FM
162
163