Article View: comp.unix.programmer
Article #3808Re: Example of gettext() program without autoconf
From: bvpelt
Date: Mon, 05 Feb 2001 13:51
Date: Mon, 05 Feb 2001 13:51
171 lines
5067 bytes
5067 bytes
/*
Demonstration of internationalization
--- begin - lang.po
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR Free Software Foundation, Inc.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: lang 0.1.0\n"
"POT-Creation-Date: 2001-02-02 11:55+0100\n"
"PO-Revision-Date: 2001-02-02 11:59+01:00\n"
"Last-Translator: Bart van Pelt <bart@vpelt.demon.nl>\n"
"Language-Team: NL <nl@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=ISO-8859-1\n"
"Content-Transfer-Encoding: 8-bit\n"
#: lang.cxx:5
msgid "Start call_b"
msgstr "Start aanroep call_b"
#: lang.cxx:9
msgid "End call_b with status "
msgstr "Einde aanroep call_b met status "
#: lang.cxx:16
msgid "Start call_a"
msgstr "Start aanroep call_a"
#: lang.cxx:22
msgid "End call_a with status "
msgstr "Einde aanroep call_a met status "
#: lang.cxx:29
msgid "Start main"
msgstr "Start aanroep main"
#: lang.cxx:35
msgid "End main with status "
msgstr "Einde aanroep main met status "
--- begin - lang.po
compile language definition
msgfmt -o lang.mo lang.po
place language specific file to correct place
LOCALEDIR = /usr/share/locale
PACKAGE = lang
cp lang.mo /usr/share/locale/nl/LC_MESSAGES
set environment variable
export LANG=nl
run program
$ lang
Start aanroep main
Start aanroep call_a
Start aanroep call_b
Einde aanroep call_b met status 3
Einde aanroep call_a met status 3
Einde aanroep main met status 3
unset lang
$ lang
Start main
Start call_a
Start call_b
End call_b with status 3
End call_a with status 3
End main with status 3
*/
#include <locale.h>
#include <libintl.h>
#include <iostream>
#define PACKAGE "lang"
#define LOCALEDIR "/usr/share/locale"
int call_b(int pStatus)
{
cout << gettext("Start call_b") << endl;
int status = pStatus + 1;
cout << gettext("End call_b with status ") << status << endl;
return status;
}
int call_a(int pStatus)
{
cout << gettext("Start call_a") << endl;
int status = pStatus + 1;
status = call_b(status);
cout << gettext("End call_a with status ") << status << endl;
return status;
}
int main(int argc, char * argv[])
{
setlocale(LC_ALL, "");
textdomain(PACKAGE);
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(PACKAGE);
cout << gettext("Start main") << endl;
int status = 1;
status = call_a(status);
cout << gettext("End main with status ") << status << endl;
return status;
}
In article <3A623AF2.6090302@uci.edu>,
Charlie Zender <zender@uci.edu> wrote:
> Thanks for the info.
>
> OK, after much trial and error I now have some i18n features
implemented
> in a single program
>
> 3 simple questions:
> 1. Where are discussions about i18n and l10n "on-topic"? is
> gnu.misc.discuss the right place? I could not find any active
newsgroups
> with discussions of i18n, bot comp.std.internat and
> comp.software.international seem inactive.
>
> 2. What do "po" and "mo" stand for? just curious
>
> 3. Currently I am testing my i18n features by invoking, e.g., export
> LANG=es at the command line. My spanish translation shows up fine, but
> it uses, i think, the default RedHat 7 character set. How do I change
> the character set in my xterms to be, say, iso-8859 so that things
like
> accented characters have a better chance of showing up correctly?
> export LANG=es changes all of the LC_* tokens, but apparently the
> xterm still uses the ascii character set. I want to know how to tell
> a given xterm to really be a spanish/french/... xterm and use the
> correct character set and keyboard mapping.
>
> Thanks,
> Charlie
> --
> Charlie Zender zender@uci.edu (949) 824-2987/FAX-3256, Department of
> Earth System Science, University of California, Irvine CA 92697-3100
>
>
Sent via Deja.com
http://www.deja.com/
Technical Details
Message-ID:
<95mb4e$nrm$1@nnrp1.deja.com>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!nntp2.deja.com!nnrp1.deja.com!not-for-mailReferences:
<3A58033D.1040505@uci.edu> <izn66jlc4qb.fsf@iki.fi> <3A623AF2.6090302@uci.edu>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc89c,6c31fbd9f931131d X-Google-Attributes: gidfc89c,public X-Google-Thread: 1025b4,6c31fbd9f931131d X-Google-Attributes: gid1025b4,public X-Google-ArrivalTime: 2001-02-05 06:00:12 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!sn-xit-01!supernews.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!cpk-news-hub1.bbnplanet.com!news.gtei.net!nntp2.deja.com!nnrp1.deja.com!not-for-mail From: bvpelt@my-deja.com Newsgroups: comp.unix.programmer,gnu.misc.discuss Subject: Re: Example of gettext() program without autoconf Date: Mon, 05 Feb 2001 13:51:14 GMT Organization: Deja.com Lines: 171 Message-ID: <95mb4e$nrm$1@nnrp1.deja.com> References: <3A58033D.1040505@uci.edu> <izn66jlc4qb.fsf@iki.fi> <3A623AF2.6090302@uci.edu> NNTP-Posting-Host: 212.189.182.151 X-Article-Creation-Date: Mon Feb 05 13:51:14 2001 GMT X-Http-User-Agent: Mozilla/4.75 [en] (X11; U; Linux 2.2.14-5.2 i586) X-Http-Proxy: 1.0 csu021.cs.kadaster.nl:8080 (Squid/2.2.STABLE4), 1.0 x51.deja.com:80 (Squid/1.1.22) for client 10.51.100.8, 212.189.182.151 X-MyDeja-Info: XMYDJUIDbvpelt