]> git.saurik.com Git - wxWidgets.git/blob - docs/latex/wx/tnoneng.tex
*** empty log message ***
[wxWidgets.git] / docs / latex / wx / tnoneng.tex
1 \section{Writing non-English applications}\label{nonenglishoverview}
2
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.
13
14 Please read \helpref{Internationalization}{internationalization} which
15 describes locales concept.
16
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.
19
20
21 \wxheading{Locales}
22
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}).
27
28 Standard .po file begins with a header like this:
29
30 \begin{verbatim}
31 # SOME DESCRIPTIVE TITLE.
32 # Copyright (C) YEAR Free Software Foundation, Inc.
33 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
34 #
35 #, fuzzy
36 msgid ""
37 msgstr ""
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"
43 "MIME-Version: 1.0\n"
44 "Content-Type: text/plain; charset=CHARSET\n"
45 "Content-Transfer-Encoding: ENCODING\n"
46 \end{verbatim}
47
48 Notice these two lines:
49
50 \begin{verbatim}
51 #, fuzzy
52 "Content-Type: text/plain; charset=CHARSET\n"
53 \end{verbatim}
54
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
57 translated messages.
58
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:
61
62 \begin{verbatim}
63 # SOME DESCRIPTIVE TITLE.
64 # Copyright (C) YEAR Free Software Foundation, Inc.
65 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
66 #
67 msgid ""
68 msgstr ""
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"
74 "MIME-Version: 1.0\n"
75 "Content-Type: text/plain; charset=iso8859-2\n"
76 "Content-Transfer-Encoding: ENCODING\n"
77 \end{verbatim}
78
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).
81
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
92 (if ever) used.
93
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!
98
99
100
101 \wxheading{Font mapping}
102
103 You can use \helpref{wxEncodingConverter}{wxencodingconverter} and
104 \helpref{wxFontMapper}{wxfontmapper} to display text:
105
106 \begin{verbatim}
107 if (!wxTheFontMapper->IsEncodingAvailable(enc, facename))
108 {
109 wxFontEncoding alternative;
110 if (wxTheFontMapper->GetAltForEncoding(enc, &alternative,
111 facename, FALSE))
112 {
113 wxEncodingConverted encconv;
114 if (!encconv.Init(enc, alternative))
115 ...failure...
116 else
117 text = encconv.Convert(text);
118 }
119 else
120 ...failure...
121 }
122 ...display text...
123 \end{verbatim}
124
125
126 \wxheading{Converting data}
127
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}.
131
132
133
134
135 \wxheading{Help files}
136
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
139 META tag, e.g.
140
141 \begin{verbatim}
142 <meta http-equiv="Content-Type" content="iso8859-2">
143 \end{verbatim}
144
145 and that hhp project file contains one additional line in {\tt OPTIONS}
146 section:
147
148 \begin{verbatim}
149 Charset=iso8859-2
150 \end{verbatim}
151
152 This additional entry tells HTML help controller what encoding is used
153 in contents and index tables.