]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/tnoneng.tex
define NO_GCC_PRAGMA in wx-config output on Darwin
[wxWidgets.git] / docs / latex / wx / tnoneng.tex
... / ...
CommitLineData
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.
8
9wxWindows library provides mechanism that helps you avoid distributing many
10identical, only differently encoded, packages with your application
11(e.g. help files and menu items in iso8859-13 and windows-1257). Thanks
12to this mechanism you can, for example, distribute only iso8859-13 data
13and it will be handled transparently under all systems.
14
15Please read \helpref{Internationalization}{internationalization} which
16describes the locales concept.
17
18In the following text, wherever {\it iso8859-2} and {\it windows-1250} are
19used, any encodings are meant and any encodings may be substituted there.
20
21\wxheading{Locales}
22
23The best way to ensure correctly displayed texts in a GUI across platforms
24is to use locales. Write your in-code messages in English or without
25diacritics and put real messages into the message catalog (see
26\helpref{Internationalization}{internationalization}).
27
28A 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#
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
47Note this particular line:
48
49\begin{verbatim}
50"Content-Type: text/plain; charset=CHARSET\n"
51\end{verbatim}
52
53It specifies the charset used by the catalog. All strings in the catalog
54are encoded using this charset.
55
56You have to fill in proper charset information. Your .po file may look like this
57after doing so:
58
59\begin{verbatim}
60# SOME DESCRIPTIVE TITLE.
61# Copyright (C) YEAR Free Software Foundation, Inc.
62# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
63#
64msgid ""
65msgstr ""
66"Project-Id-Version: PACKAGE VERSION\n"
67"POT-Creation-Date: 1999-02-19 16:03+0100\n"
68"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
69"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
70"Language-Team: LANGUAGE <LL@li.org>\n"
71"MIME-Version: 1.0\n"
72"Content-Type: text/plain; charset=iso8859-2\n"
73"Content-Transfer-Encoding: 8bit\n"
74\end{verbatim}
75
76(Make sure that the header is {\bf not} marked as {\it fuzzy}.)
77
78wxWindows is able to use this catalog under any supported platform
79(although iso8859-2 is a Unix encoding and is normally not understood by
80Windows).
81
82How is this done? When you tell the wxLocale class to load a message catalog that
83contains correct header, it checks the charset. The catalog is then converted
84to the charset used (see
85\helpref{wxLocale::GetSystemEncoding}{wxlocalegetsystemencoding} and
86\helpref{wxLocale::GetSystemEncodingName}{wxlocalegetsystemencodingname}) by
87user's operating system. This is default behaviour of the
88\helpref{wxLocale}{wxlocale} class; you can disable it by {\bf not} passing
89{\tt wxLOCALE\_CONV\_ENCODING} to \helpref{wxLocale::Init}{wxlocaleinit}.
90
91\wxheading{Font mapping}
92
93You can use \helpref{wxMBConv classes}{mbconvclasses} and
94\helpref{wxFontMapper}{wxfontmapper} to display text:
95
96\begin{verbatim}
97if (!wxFontMapper::Get()->IsEncodingAvailable(enc, facename))
98{
99 wxFontEncoding alternative;
100 if (wxFontMapper::Get()->GetAltForEncoding(enc, &alternative,
101 facename, false))
102 {
103 wxCSConv convFrom(wxFontMapper::Get()->GetEncodingName(enc));
104 wxCSConv convTo(wxFontMapper::Get()->GetEncodingName(alternative));
105 text = wxString(text.mb_str(convFrom), convTo);
106 }
107 else
108 ...failure (or we may try iso8859-1/7bit ASCII)...
109}
110...display text...
111\end{verbatim}
112
113\wxheading{Converting data}
114
115You may want to store all program data (created documents etc.) in
116the same encoding, let's say {\tt utf-8}. You can use
117\helpref{wxCSConv}{wxcsconv} class to convert data to encoding used by the
118system your application is running on (see
119\helpref{wxLocale::GetSystemEncoding}{wxlocalegetsystemencoding}).
120
121\wxheading{Help files}
122
123If you're using \helpref{wxHtmlHelpController}{wxhtmlhelpcontroller} there is
124no problem at all. You must only make sure that all the HTML files contain
125the META tag, e.g.
126
127\begin{verbatim}
128<meta http-equiv="Content-Type" content="text/html; charset=iso8859-2">
129\end{verbatim}
130
131and that the hhp project file contains one additional line in the {\tt OPTIONS}
132section:
133
134\begin{verbatim}
135Charset=iso8859-2
136\end{verbatim}
137
138This additional entry tells the HTML help controller what encoding is used
139in contents and index tables.
140