]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tnoneng.tex
Fixed status bar probs,
[wxWidgets.git] / docs / latex / wx / tnoneng.tex
CommitLineData
9005a56e
VS
1\section{Writing non-English applications}\label{nonenglishoverview}
2
3This article describes how to write applications that communicate with
4user in language other than English. Unfortunately many languages use
5different charsets under Unix and Windows (and other platforms, to make
6situation even more complicated). These charsets usually differ in so
7many characters it is impossible to use same texts under all platforms.
8wxWindows provide mechanism that helps you avoid distributing many
9identical, only differently encoded, packages with your application
10(e.g. help files and menu items in iso8859-13 and windows-1257). Thanks
11to this mechanism you can distribute only let's say iso8859-13 data
12and it will be handled transparently under all systems.
13
54cd4332 14Please read \helpref{Internationalization}{internationalization} which
9005a56e
VS
15describes locales concept.
16
17Whereever in the following text {\it iso8859-2} and {\it windows-1250} are
18used, any encodings are meant and any encodings may be substituted there.
19
20
21\wxheading{Locales}
22
54cd4332
VS
23The best way how to ensure correctly displayed texts in GUI across platforms
24is to use locales. Write your in-code messages in English or without
25diacritics and put real messages into message catalog (see
26\helpref{Internationalization}{internationalization}).
9005a56e 27
54cd4332
VS
28Standard .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
36msgid ""
37msgstr ""
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
48Notice these two lines:
49
50\begin{verbatim}
51#, fuzzy
52"Content-Type: text/plain; charset=CHARSET\n"
53\end{verbatim}
54
55The first tells {\it msgfmt} compiler not to include string "" (empty)
56to compiled .mo catalog. Second one informs about charset used to write
57translated messages.
58
59You have to do 2 things: fill-in proper charset information and delete
60the {\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#
67msgid ""
68msgstr ""
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
79wxWindows is able to use this catalog under any supported platform
80(although iso8859-2 is Unix encoding and is not understood by Windows).
81
82How is this done? When you tell wxLocale class to load message catalog that
83contains the header (msgid "". Normal .mo catalogs do {\bf not} contain it,
84you must remove the line with {\it fuzzy}!), it checks the charset. If the
85charset is "alien" on the platform the program is currently running (e.g.
86any of ISO encodings under Windows or CP12XX under Unix) it uses
87\helpref{wxEncodingConverter::GetPlatformEquivalents}{wxencodingconvertergetplatformequivalents}
88to obtain encoding that is more common on this platform and converts
89the message catalog to this encoding. Note that it does {\bf not} check
90for presence of this encoding! It only assumes that it is always better to
91have strings in platform native encoding than in an encoding that is rarely
92(if ever) used.
93
94The behaviour described about is disabled by default.
95You must set {\it bConvertEncoding} to TRUE in
96\helpref{wxLocale constructor}{wxlocaledefctor} in order to enable
97runtime encoding conversion!
9005a56e 98
9005a56e 99
9005a56e
VS
100
101\wxheading{Font mapping}
102
54cd4332
VS
103You can use \helpref{wxEncodingConverter}{wxencodingconverter} and
104\helpref{wxFontMapper}{wxfontmapper} to display text:
105
106\begin{verbatim}
107if (!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
128You may want to store all program data (created documents etc.) in
129same encoding, let's say windows1250. Obviously, the best way would
130be to use \helpref{wxEncodingConverter}{wxencodingconverter}.
131
132
133
9005a56e
VS
134
135\wxheading{Help files}
136
137If you're using \helpref{wxHtmlHelpController}{wxhtmlhelpcontroller} there is
138no problem at all. You must only make sure that all HTML files contain
139META tag, e.g.
140
141\begin{verbatim}
142<meta http-equiv="Content-Type" content="iso8859-2">
143\end{verbatim}
144
145and that hhp project file contains one additional line in {\tt OPTIONS}
146section:
147
148\begin{verbatim}
149Charset=iso8859-2
150\end{verbatim}
151
152This additional entry tells HTML help controller what encoding is used
153in contents and index tables.