162 lines
5.1 KiB
Plaintext
162 lines
5.1 KiB
Plaintext
|
||
Using national language support (NLS) in FreeType
|
||
=================================================
|
||
|
||
21. 1. 1998
|
||
Erwin Dieterich
|
||
|
||
|
||
1) Introduction
|
||
2) Using gettext (user's view)
|
||
3) Using gettext (programmer's view)
|
||
4) Using gettext (maintainer's view)
|
||
5) How can I switch off NLS? I don't need/want it.
|
||
|
||
|
||
Only Unix NLS using gettext() is covered here. If you are able to
|
||
help with internationalization (i18n) for different operating
|
||
systems, please e-mail me at Erwin.Dieterich.ED@Bayer-AG.de.
|
||
|
||
|
||
|
||
1) Introduction
|
||
|
||
If a program is to be used by people who are not fluent speakers of
|
||
English, the first thing they will ask for is communication in their
|
||
native language. If someone tries to implement NLS in a program
|
||
using only #ifdefs and other such programming strategies, it's
|
||
likely that this someone will get nowhere.
|
||
|
||
Gettext() is a possible way to help. Only minimal extra programming
|
||
effort is needed; the translations are implemented separately from
|
||
the program, and it is not necessary to recompile a program if you
|
||
want to switch the messages to a different language. If you wouldd
|
||
like to know more about gettext(), I recommend reading the GNU
|
||
gettext tools manual, written by Ulrich Drepper, Jim Meyering, and
|
||
Francois Pinard.
|
||
|
||
Currently supported languages are:
|
||
|
||
Czech (cz) translator: Pavel Kankovsky
|
||
<peak@kerberos.troja.mff.cuni.cz>
|
||
Dutch (nl) translator: Gertjan de Back <gertjan.de.back@pi.net>
|
||
French (fr) translator: David Turner <david.turner@freetype.org>
|
||
German (de) translator: Erwin Dieterich
|
||
<erwin.dieterich.ed@bayer-ag.de>
|
||
Spain (es) translator: Miguel A. Perez Valdenebro
|
||
<map@fujitsu.es>
|
||
|
||
Currently supported programs in the `test' directory are:
|
||
|
||
ftlint
|
||
ftdump
|
||
fterror
|
||
ftmetric
|
||
ftsbit
|
||
|
||
|
||
2) Using gettext (user's view)
|
||
|
||
Using gettext as an end user is very simple. If FreeType is
|
||
correctly installed on your computer, you can simply issue an
|
||
`export LANG=<language id>' in your Bourne shell or `setenv
|
||
LANG=<language id>' if you are using csh. That's all. In order to
|
||
switch back to English, just use `export LANG=' or `setenv LANG='.
|
||
|
||
<language id> is a two character code describing your language:
|
||
de=German, fr=French etc. Every supported language has its own
|
||
<language id>.po file in the `po' directory of FreeType. If your
|
||
language is not there you should consider contributing a
|
||
translation. Just e-mail me. Here is a transcript of what `export
|
||
LANG=<language id>' does:
|
||
|
||
test> ftlint 24 furiosot.ttf
|
||
Could not find or open furiosot.ttf.
|
||
FreeType error message: OS/2 table missing.
|
||
|
||
test> export LANG=de
|
||
test> ftlint 24 furiosot.ttf
|
||
Datei `furiosot.ttf' konnte nicht gefunden oder ge<67>ffnet werden.
|
||
FreeType Fehlermeldung: `OS/2'-Tabelle fehlt.
|
||
|
||
test> export LANG=
|
||
test> ftlint 24 furiosot.ttf
|
||
Could not find or open file furioso.ttf.
|
||
FreeType error message: OS/2 table missing.
|
||
|
||
Doesn't this look good? But what if nothing happens if you set
|
||
LANG? Here are some hints:
|
||
|
||
First: Is your language really supported? If it is, you need to be
|
||
sure that you have gettext() installed (if you are sitting at a
|
||
Linux box, chances are very good that you have). If you compiled
|
||
FreeType yourself and nothing strange happened, then your version of
|
||
FreeType has NLS compiled in, as this is the default, unless you
|
||
forgot to install the translation files in the right places (`make
|
||
install' in the po/ directory should be enough, but you need root
|
||
permissions as these files are installed somewhere in /usr/local) --
|
||
good luck :-)
|
||
|
||
|
||
3) Using gettext (programmer's view)
|
||
|
||
If you intend to use NLS in your program, you just need to make a
|
||
few simple changes. Here I only describe how NLS is enabled in the
|
||
programs that come with FreeType in test/. If you would like to add
|
||
NLS to other programs using FreeType as well, take a look at
|
||
FreeType's installation files; you can probably use these files as a
|
||
model.
|
||
|
||
Every string that should be translated needs gettext() around it.
|
||
So
|
||
|
||
Message( "Usage: %s fontname[.ttf|.ttc]\n\n",
|
||
execname );
|
||
|
||
becomes
|
||
|
||
Message( gettext( "Usage: %s fontname[.ttf|.ttc]\n\n" ),
|
||
execname );
|
||
|
||
|
||
Yes, it's that simple. Next you need to initialize gettext. Put
|
||
the following in the header section of your file:
|
||
|
||
#include "ft_conf.h"
|
||
#ifdef HAVE_LIBINTL_H
|
||
#include <libintl.h>
|
||
#endif
|
||
|
||
#ifndef HAVE_LIBINTL_H
|
||
#define gettext( x ) ( x )
|
||
#endif
|
||
|
||
and this at the very beginning of your main program:
|
||
|
||
#ifdef HAVE_LIBINTL_H
|
||
setlocale(LC_ALL, "");
|
||
bindtextdomain( "freetype", LOCALEDIR );
|
||
textdomain( "freetype" );
|
||
#endif
|
||
|
||
|
||
That's all. Just have a look at fterror.c in test/.
|
||
|
||
|
||
4) Using gettext (maintainer's view)
|
||
|
||
I am too lazy today :-) If something isn't clear, just ask me.
|
||
|
||
|
||
5) How can I switch off NLS? I don't need/want it.
|
||
|
||
Just say `configure --disable-nls' and recompile FreeType.
|
||
|
||
|
||
If you have any questions or comments regarding this short
|
||
introduction to NLS & FreeType, feel free to email me at
|
||
Erwin.Dieterich.ED@Bayer-AG.de.
|
||
|
||
|
||
--- end of i18n.txt ---
|