2 Using national language support (NLS) in FreeType
3 =================================================
10 2) Using gettext (user's view)
11 3) Using gettext (programmer's view)
12 4) Using gettext (maintainer's view)
13 5) How can I switch off NLS? I don't need/want it.
16 Only Unix NLS using gettext() is covered here. If you are able to
17 help with internationalization (i18n) for different operating
18 systems, please e-mail me at Erwin.Dieterich.ED@Bayer-AG.de.
24 If a program is to be used by people who are not fluent speakers of
25 English, the first thing they will ask for is communication in their
26 native language. If someone tries to implement NLS in a program
27 using only #ifdefs and other such programming strategies, it's
28 likely that this someone will get nowhere.
30 Gettext() is a possible way to help. Only minimal extra programming
31 effort is needed; the translations are implemented separately from
32 the program, and it is not necessary to recompile a program if you
33 want to switch the messages to a different language. If you wouldd
34 like to know more about gettext(), I recommend reading the GNU
35 gettext tools manual, written by Ulrich Drepper, Jim Meyering, and
38 Currently supported languages are:
40 Czech (cz) translator: Pavel Kankovsky
41 <peak@kerberos.troja.mff.cuni.cz>
42 Dutch (nl) translator: Gertjan de Back <gertjan.de.back@pi.net>
43 French (fr) translator: David Turner <david.turner@freetype.org>
44 German (de) translator: Erwin Dieterich
45 <erwin.dieterich.ed@bayer-ag.de>
46 Spain (es) translator: Miguel A. Perez Valdenebro
49 Currently supported programs in the `test' directory are:
58 2) Using gettext (user's view)
60 Using gettext as an end user is very simple. If FreeType is
61 correctly installed on your computer, you can simply issue an
62 `export LANG=<language id>' in your Bourne shell or `setenv
63 LANG=<language id>' if you are using csh. That's all. In order to
64 switch back to English, just use `export LANG=' or `setenv LANG='.
66 <language id> is a two character code describing your language:
67 de=German, fr=French etc. Every supported language has its own
68 <language id>.po file in the `po' directory of FreeType. If your
69 language is not there you should consider contributing a
70 translation. Just e-mail me. Here is a transcript of what `export
71 LANG=<language id>' does:
73 test> ftlint 24 furiosot.ttf
74 Could not find or open furiosot.ttf.
75 FreeType error message: OS/2 table missing.
78 test> ftlint 24 furiosot.ttf
79 Datei `furiosot.ttf' konnte nicht gefunden oder geƶffnet werden.
80 FreeType Fehlermeldung: `OS/2'-Tabelle fehlt.
83 test> ftlint 24 furiosot.ttf
84 Could not find or open file furioso.ttf.
85 FreeType error message: OS/2 table missing.
87 Doesn't this look good? But what if nothing happens if you set
88 LANG? Here are some hints:
90 First: Is your language really supported? If it is, you need to be
91 sure that you have gettext() installed (if you are sitting at a
92 Linux box, chances are very good that you have). If you compiled
93 FreeType yourself and nothing strange happened, then your version of
94 FreeType has NLS compiled in, as this is the default, unless you
95 forgot to install the translation files in the right places (`make
96 install' in the po/ directory should be enough, but you need root
97 permissions as these files are installed somewhere in /usr/local) --
101 3) Using gettext (programmer's view)
103 If you intend to use NLS in your program, you just need to make a
104 few simple changes. Here I only describe how NLS is enabled in the
105 programs that come with FreeType in test/. If you would like to add
106 NLS to other programs using FreeType as well, take a look at
107 FreeType's installation files; you can probably use these files as a
110 Every string that should be translated needs gettext() around it.
113 Message( "Usage: %s fontname[.ttf|.ttc]\n\n",
118 Message( gettext( "Usage: %s fontname[.ttf|.ttc]\n\n" ),
122 Yes, it's that simple. Next you need to initialize gettext. Put
123 the following in the header section of your file:
126 #ifdef HAVE_LIBINTL_H
130 #ifndef HAVE_LIBINTL_H
131 #define gettext( x ) ( x )
134 and this at the very beginning of your main program:
136 #ifdef HAVE_LIBINTL_H
137 setlocale(LC_ALL, "");
138 bindtextdomain( "freetype", LOCALEDIR );
139 textdomain( "freetype" );
143 That's all. Just have a look at fterror.c in test/.
146 4) Using gettext (maintainer's view)
148 I am too lazy today :-) If something isn't clear, just ask me.
151 5) How can I switch off NLS? I don't need/want it.
153 Just say `configure --disable-nls' and recompile FreeType.
156 If you have any questions or comments regarding this short
157 introduction to NLS & FreeType, feel free to email me at
158 Erwin.Dieterich.ED@Bayer-AG.de.
161 --- end of i18n.txt ---