]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/nonenglish.h
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: topic overview
4 // Author: wxWidgets team
6 // Licence: wxWindows license
7 /////////////////////////////////////////////////////////////////////////////
11 @page nonenglish_overview Writing non-English applications
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
19 The wxWidgets library provides a mechanism that helps you avoid distributing many
20 identical, only differently encoded, packages with your application
21 (e.g. help files and menu items in iso8859-13 and windows-1257). Thanks
22 to this mechanism you can, for example, distribute only iso8859-13 data
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.
29 The best way to ensure correctly displayed texts in a GUI across platforms
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
32 #Internationalization).
33 A standard .po file begins with a header like this:
36 # SOME DESCRIPTIVE TITLE.
37 # Copyright (C) YEAR Free Software Foundation, Inc.
38 # FIRST AUTHOR EMAIL@ADDRESS, YEAR.
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"
48 "Content-Type: text/plain; charset=CHARSET\n"
49 "Content-Transfer-Encoding: ENCODING\n"
52 Note this particular line:
55 "Content-Type: text/plain; charset=CHARSET\n"
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
64 # SOME DESCRIPTIVE TITLE.
65 # Copyright (C) YEAR Free Software Foundation, Inc.
66 # FIRST AUTHOR EMAIL@ADDRESS, YEAR.
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"
76 "Content-Type: text/plain; charset=iso8859-2\n"
77 "Content-Transfer-Encoding: 8bit\n"
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
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:
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:
108 locale.AddCatalog(_T("myapp"),
109 wxLANGUAGE_GERMAN, _T("iso-8859-1"));
116 You can use @ref mbconvclasses_overview and
117 #wxFontMapper to display text:
120 if (!wxFontMapper::Get()-IsEncodingAvailable(enc, facename))
122 wxFontEncoding alternative;
123 if (wxFontMapper::Get()-GetAltForEncoding(enc, ,
126 wxCSConv convFrom(wxFontMapper::Get()-GetEncodingName(enc));
127 wxCSConv convTo(wxFontMapper::Get()-GetEncodingName(alternative));
128 text = wxString(text.mb_str(convFrom), convTo);
131 ...failure (or we may try iso8859-1/7bit ASCII)...
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).
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
148 meta http-equiv="Content-Type" content="text/html; charset=iso8859-2"
151 and that the hhp project file contains one additional line in the @c OPTIONS
158 This additional entry tells the HTML help controller what encoding is used
159 in contents and index tables.