]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/tnoneng.tex
wxFTP docs update and a small fix to wxString overview (Unicode *is* supported
[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
f6bcfd97 11to this mechanism you can, for example, distribute only iso8859-13 data
9005a56e
VS
12and it will be handled transparently under all systems.
13
54cd4332 14Please read \helpref{Internationalization}{internationalization} which
f6bcfd97 15describes the locales concept.
9005a56e 16
f6bcfd97 17In the following text, wherever {\it iso8859-2} and {\it windows-1250} are
9005a56e
VS
18used, any encodings are meant and any encodings may be substituted there.
19
9005a56e
VS
20\wxheading{Locales}
21
f6bcfd97 22The best way to ensure correctly displayed texts in a GUI across platforms
54cd4332 23is to use locales. Write your in-code messages in English or without
f6bcfd97 24diacritics and put real messages into the message catalog (see
54cd4332 25\helpref{Internationalization}{internationalization}).
9005a56e 26
f6bcfd97 27A standard .po file begins with a header like this:
54cd4332
VS
28
29\begin{verbatim}
30# SOME DESCRIPTIVE TITLE.
31# Copyright (C) YEAR Free Software Foundation, Inc.
32# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
33#
34#, fuzzy
35msgid ""
36msgstr ""
37"Project-Id-Version: PACKAGE VERSION\n"
38"POT-Creation-Date: 1999-02-19 16:03+0100\n"
39"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
40"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
41"Language-Team: LANGUAGE <LL@li.org>\n"
42"MIME-Version: 1.0\n"
43"Content-Type: text/plain; charset=CHARSET\n"
44"Content-Transfer-Encoding: ENCODING\n"
45\end{verbatim}
46
47Notice these two lines:
48
49\begin{verbatim}
50#, fuzzy
51"Content-Type: text/plain; charset=CHARSET\n"
52\end{verbatim}
53
f6bcfd97
BP
54The first tells the {\it msgfmt} compiler not to include "" (the empty string)
55in compiled .mo catalog. The second one specifies the charset used to write
54cd4332
VS
56translated messages.
57
f6bcfd97 58You have to do two things: fill in proper charset information and delete
54cd4332
VS
59the {\tt fuzzy} line. Your .po file may look like this after doing so:
60
61\begin{verbatim}
62# SOME DESCRIPTIVE TITLE.
63# Copyright (C) YEAR Free Software Foundation, Inc.
64# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
65#
66msgid ""
67msgstr ""
68"Project-Id-Version: PACKAGE VERSION\n"
69"POT-Creation-Date: 1999-02-19 16:03+0100\n"
70"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
71"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
72"Language-Team: LANGUAGE <LL@li.org>\n"
73"MIME-Version: 1.0\n"
74"Content-Type: text/plain; charset=iso8859-2\n"
75"Content-Transfer-Encoding: ENCODING\n"
76\end{verbatim}
77
78wxWindows is able to use this catalog under any supported platform
f6bcfd97 79(although iso8859-2 is a Unix encoding and is not understood by Windows).
54cd4332 80
f6bcfd97
BP
81How is this done? When you tell the wxLocale class to load a message catalog that
82contains the header (msgid ""; normal .mo catalogs do {\bf not} contain it,
54cd4332
VS
83you must remove the line with {\it fuzzy}!), it checks the charset. If the
84charset is "alien" on the platform the program is currently running (e.g.
f6bcfd97 85any of ISO encodings under Windows or CP12XX under Unix) it uses
54cd4332 86\helpref{wxEncodingConverter::GetPlatformEquivalents}{wxencodingconvertergetplatformequivalents}
f6bcfd97 87to obtain an encoding that is more common on this platform and converts
54cd4332
VS
88the message catalog to this encoding. Note that it does {\bf not} check
89for presence of this encoding! It only assumes that it is always better to
90have strings in platform native encoding than in an encoding that is rarely
91(if ever) used.
92
f6bcfd97 93The behaviour described above is disabled by default.
54cd4332
VS
94You must set {\it bConvertEncoding} to TRUE in
95\helpref{wxLocale constructor}{wxlocaledefctor} in order to enable
f6bcfd97 96runtime encoding conversion.
9005a56e 97
9005a56e
VS
98\wxheading{Font mapping}
99
528e0faf 100You can use \helpref{wxEncodingConverter}{wxencodingconverter} and
54cd4332
VS
101\helpref{wxFontMapper}{wxfontmapper} to display text:
102
103\begin{verbatim}
104if (!wxTheFontMapper->IsEncodingAvailable(enc, facename))
105{
106 wxFontEncoding alternative;
107 if (wxTheFontMapper->GetAltForEncoding(enc, &alternative,
108 facename, FALSE))
109 {
110 wxEncodingConverted encconv;
111 if (!encconv.Init(enc, alternative))
112 ...failure...
113 else
114 text = encconv.Convert(text);
115 }
116 else
117 ...failure...
118}
119...display text...
120\end{verbatim}
121
54cd4332
VS
122\wxheading{Converting data}
123
124You may want to store all program data (created documents etc.) in
f6bcfd97 125the same encoding, let's say windows1250. Obviously, the best way would
54cd4332
VS
126be to use \helpref{wxEncodingConverter}{wxencodingconverter}.
127
9005a56e
VS
128\wxheading{Help files}
129
130If you're using \helpref{wxHtmlHelpController}{wxhtmlhelpcontroller} there is
f6bcfd97
BP
131no problem at all. You must only make sure that all the HTML files contain
132the META tag, e.g.
9005a56e
VS
133
134\begin{verbatim}
ea129d33 135<meta http-equiv="Content-Type" content="text/html; charset=iso8859-2">
9005a56e
VS
136\end{verbatim}
137
f6bcfd97 138and that the hhp project file contains one additional line in the {\tt OPTIONS}
9005a56e
VS
139section:
140
141\begin{verbatim}
142Charset=iso8859-2
143\end{verbatim}
144
f6bcfd97 145This additional entry tells the HTML help controller what encoding is used
9005a56e 146in contents and index tables.
457e6c54 147