1 \section{Writing non-English applications
}\label{nonenglishoverview
}
3 This article describes how to write applications that communicate with
4 user in language other than English. Unfortunately many languages use
5 different charsets under Unix and Windows (and other platforms, to make
6 situation even more complicated). These charsets usually differ in so
7 many characters it is impossible to use same texts under all platforms.
8 wxWindows provide mechanism that helps you avoid distributing many
9 identical, only differently encoded, packages with your application
10 (e.g. help files and menu items in iso8859-
13 and windows-
1257). Thanks
11 to this mechanism you can distribute only let's say iso8859-
13 data
12 and it will be handled transparently under all systems.
14 Please read
\helpref{Internationalization
}{internationalization
} which
15 describes locales concept.
17 Whereever in the following text
{\it iso8859-
2} and
{\it windows-
1250} are
18 used, any encodings are meant and any encodings may be substituted there.
23 The best way how to ensure correctly displayed texts in GUI across platforms
24 is to use locales. Write your in-code messages in English or without
25 diacritics and put real messages into message catalog (see
26 \helpref{Internationalization
}{internationalization
}).
28 Standard .po file begins with a header like this:
31 # SOME DESCRIPTIVE TITLE.
32 # Copyright (C) YEAR Free Software Foundation, Inc.
33 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
38 "Project-Id-Version: PACKAGE VERSION
\n"
39 "POT-Creation-Date:
1999-
02-
19 16:
03+
0100\n"
40 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
\n"
41 "Last-Translator: FULL NAME <EMAIL@ADDRESS>
\n"
42 "Language-Team: LANGUAGE <LL@li.org>
\n"
44 "Content-Type: text/plain; charset=CHARSET
\n"
45 "Content-Transfer-Encoding: ENCODING
\n"
48 Notice these two lines:
52 "Content-Type: text/plain; charset=CHARSET
\n"
55 The first tells
{\it msgfmt
} compiler not to include string "" (empty)
56 to compiled .mo catalog. Second one informs about charset used to write
59 You have to do
2 things: fill-in proper charset information and delete
60 the
{\tt fuzzy
} line. Your .po file may look like this after doing so:
63 # SOME DESCRIPTIVE TITLE.
64 # Copyright (C) YEAR Free Software Foundation, Inc.
65 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
69 "Project-Id-Version: PACKAGE VERSION
\n"
70 "POT-Creation-Date:
1999-
02-
19 16:
03+
0100\n"
71 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE
\n"
72 "Last-Translator: FULL NAME <EMAIL@ADDRESS>
\n"
73 "Language-Team: LANGUAGE <LL@li.org>
\n"
75 "Content-Type: text/plain; charset=iso8859-
2\n"
76 "Content-Transfer-Encoding: ENCODING
\n"
79 wxWindows is able to use this catalog under any supported platform
80 (although iso8859-
2 is Unix encoding and is not understood by Windows).
82 How is this done? When you tell wxLocale class to load message catalog that
83 contains the header (msgid "". Normal .mo catalogs do
{\bf not
} contain it,
84 you must remove the line with
{\it fuzzy
}!), it checks the charset. If the
85 charset is "alien" on the platform the program is currently running (e.g.
86 any of ISO encodings under Windows or CP12XX under Unix) it uses
87 \helpref{wxEncodingConverter::GetPlatformEquivalents
}{wxencodingconvertergetplatformequivalents
}
88 to obtain encoding that is more common on this platform and converts
89 the message catalog to this encoding. Note that it does
{\bf not
} check
90 for presence of this encoding! It only assumes that it is always better to
91 have strings in platform native encoding than in an encoding that is rarely
94 The behaviour described about is disabled by default.
95 You must set
{\it bConvertEncoding
} to TRUE in
96 \helpref{wxLocale constructor
}{wxlocaledefctor
} in order to enable
97 runtime encoding conversion!
101 \wxheading{Font mapping
}
103 You can use
\helpref{wxEncodingConverter
}{wxencodingconverter
} and
104 \helpref{wxFontMapper
}{wxfontmapper
} to display text:
107 if (!wxTheFontMapper->IsEncodingAvailable(enc, facename))
109 wxFontEncoding alternative;
110 if (wxTheFontMapper->GetAltForEncoding(enc, &alternative,
113 wxEncodingConverted encconv;
114 if (!encconv.Init(enc, alternative))
117 text = encconv.Convert(text);
126 \wxheading{Converting data
}
128 You may want to store all program data (created documents etc.) in
129 same encoding, let's say windows1250. Obviously, the best way would
130 be to use
\helpref{wxEncodingConverter
}{wxencodingconverter
}.
135 \wxheading{Help files
}
137 If you're using
\helpref{wxHtmlHelpController
}{wxhtmlhelpcontroller
} there is
138 no problem at all. You must only make sure that all HTML files contain
142 <meta http-equiv="Content-Type" content="iso8859-
2">
145 and that hhp project file contains one additional line in
{\tt OPTIONS
}
152 This additional entry tells HTML help controller what encoding is used
153 in contents and index tables.