]>
git.saurik.com Git - wxWidgets.git/blob - docs/doxygen/overviews/nonenglish.h
dd2e04d70e6d209ee6061f3065159595cbbc1835
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: topic overview
4 // Author: wxWidgets team
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
11 @page overview_nonenglish Writing Non-English Applications
15 This article describes how to write applications that communicate with the user
16 in a language other than English. Unfortunately many languages use different
17 charsets under Unix and Windows (and other platforms, to make the situation
18 even more complicated). These charsets usually differ in so many characters
19 that it is impossible to use the same texts under all platforms.
21 The wxWidgets library provides a mechanism that helps you avoid distributing
22 many identical, only differently encoded, packages with your application (e.g.
23 help files and menu items in iso8859-13 and windows-1257). Thanks to this
24 mechanism you can, for example, distribute only iso8859-13 data and it will be
25 handled transparently under all systems.
27 Please read the @ref overview_i18n which describes the locales concept.
29 In the following text, wherever @e iso8859-2 and @e windows-1250 are used, any
30 encodings are meant and any encodings may be substituted there.
34 @section overview_nonenglish_locales Locales
36 The best way to ensure correctly displayed texts in a GUI across platforms is
37 to use locales. Write your in-code messages in English or without diacritics
38 and put real messages into the message catalog (see @ref overview_i18n).
40 A standard .po file begins with a header like this:
43 # SOME DESCRIPTIVE TITLE.
44 # Copyright (C) YEAR Free Software Foundation, Inc.
45 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
49 "Project-Id-Version: PACKAGE VERSION\n"
50 "POT-Creation-Date: 1999-02-19 16:03+0100\n"
51 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
52 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
53 "Language-Team: LANGUAGE <LL@li.org>\n"
55 "Content-Type: text/plain; charset=CHARSET\n"
56 "Content-Transfer-Encoding: ENCODING\n"
59 Note this particular line:
62 "Content-Type: text/plain; charset=CHARSET\n"
65 It specifies the charset used by the catalog. All strings in the catalog are
66 encoded using this charset.
68 You have to fill in proper charset information. Your .po file may look like
72 # SOME DESCRIPTIVE TITLE.
73 # Copyright (C) YEAR Free Software Foundation, Inc.
74 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
78 "Project-Id-Version: PACKAGE VERSION\n"
79 "POT-Creation-Date: 1999-02-19 16:03+0100\n"
80 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
81 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
82 "Language-Team: LANGUAGE <LL@li.org>\n"
84 "Content-Type: text/plain; charset=iso8859-2\n"
85 "Content-Transfer-Encoding: 8bit\n"
88 (Make sure that the header is @b not marked as @e fuzzy.)
90 wxWidgets is able to use this catalog under any supported platform
91 (although iso8859-2 is a Unix encoding and is normally not understood by
94 How is this done? When you tell the wxLocale class to load a message catalog
95 that contains a correct header, it checks the charset. The catalog is then
96 converted to the charset used (see wxLocale::GetSystemEncoding and
97 wxLocale::GetSystemEncodingName) by the user's operating system.
100 @section overview_nonenglish_strings Non-English Strings or 8-bit Characters in Source
102 By convention, you should only use characters without diacritics (i.e. 7-bit
103 ASCII strings) for msgids in the source code and write them in English.
105 If you port software to wxWidgets, you may be confronted with legacy source
106 code containing non-English string literals. Instead of translating the strings
107 in the source code to English and putting the original strings into message
108 catalog, you may configure wxWidgets to use non-English msgids and translate to
109 English using message catalogs:
111 @li If you use the program @c xgettext to extract the strings from the source
112 code, specify the option <tt>--from-code=@<source code charset@></tt>.
113 @li Specify the source code language and charset as arguments to
114 wxLocale::AddCatalog. For example:
116 locale.AddCatalog(wxT("myapp"), wxLANGUAGE_GERMAN, wxT("iso-8859-1"));
120 @section overview_nonenglish_fontmapping Font Mapping
122 You can use @ref overview_mbconv and wxFontMapper to display text:
125 if (!wxFontMapper::Get()->IsEncodingAvailable(enc, facename))
127 wxFontEncoding alternative;
128 if (wxFontMapper::Get()->GetAltForEncoding(enc, &alternative,
131 wxCSConv convFrom(wxFontMapper::Get()->GetEncodingName(enc));
132 wxCSConv convTo(wxFontMapper::Get()->GetEncodingName(alternative));
133 text = wxString(text.mb_str(convFrom), convTo);
136 ...failure (or we may try iso8859-1/7bit ASCII)...
142 @section overview_nonenglish_converting Converting Data
144 You may want to store all program data (created documents etc.) in the same
145 encoding, let's say @c utf-8. You can use wxCSConv to convert data to the
146 encoding used by the system your application is running on (see
147 wxLocale::GetSystemEncoding).
150 @section overview_nonenglish_help Help Files
152 If you're using wxHtmlHelpController there is no problem at all. You only need
153 to make sure that all the HTML files contain the META tag:
156 <meta http-equiv="Content-Type" content="text/html; charset=iso8859-2">
159 Also, the hhp project file needs one additional line in the @c OPTIONS section:
165 This additional entry tells the HTML help controller what encoding is used in
166 contents and index tables.