🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #3814

Example of gettext() program without autoconf

#3814
From: Charlie Zender
Date: Sun, 07 Jan 2001 05:48
63 lines
3413 bytes
Hi,

There seem to be no active groups for discussing gettext(),
so I'm crossposting this to comp.unix.programmer, gnu.g++.help,
and gnu.misc.discuss.
I am trying to internationalize some C/C++ programs (NCO, see 
http://nco.sourceforge.net) and so have read the gettext()
information and tried it out. Unfortunately the documentation
is not complete and I am confused how to proceed. The basics
are clear enough, use gettext("string to be translated"), but
there does not seem to be a complete, end-to-end example.
I could not ever figure out what a PO file is but I know that
I need one!

Perhaps part
of the problem is that the manual appears to assume that one
is using autoconf to build the program. I am not. I assume
it is possible to use a simple Makefile, but the value that
some of the tokens should take is not clear. I am using
RedHat GNU/Linux 7.0 intel, and gettext-0.10.35 is installed.

If someone could please post or point me to
a simple example of a working gettext() program, complete
with compile lines and any auxiliary files, and with any
postprocessing commands (e.g., xgettext or whatever)
I would much appreciate it.

Thanks,
Charlie

P.S. Appended below is my simple, non-working code and compile line.
My questions are basic:
What should PACKAGE be? "gettext"?
What about LOCALEDIR?
Where do I store the translations?
Where is there a complete example of all this on the net?
-- 
Charlie Zender zender@uci.edu (949) 824-2987/FAX-3256, Department of
Earth System Science, University of California, Irvine CA 92697-3100

// Purpose: Simple program to demonstrate internationalization with gettext
// g++ -I. -I/usr/local/include -O -Wall -c i18n.cc -o 
/home/zender/obj/LINUX/i18n.o

#include <iostream> // Standard C++ I/O streams cout, cin
#include <string> // Standard C++ string class
#include <libintl.h> // Internationalization I18N

int main(int argc,char **argv)
{
   // i18n: gettext() replaces string within _() by appropriate language
   setlocale(LC_ALL, "");
   bindtextdomain(PACKAGE,LOCALEDIR);
   textdomain(PACKAGE);
   cout << "Testing internationalization..." << endl;
   cout << gettext("Testing internationalization...") << endl;
}



-- 
Charlie Zender zender@uci.edu (949) 824-2987/FAX-3256, Department of
Earth System Science, University of California, Irvine CA 92697-3100
Technical Details
Message-ID: <3A58033D.1040505@uci.edu>
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!news.maxwell.syr.edu!newshub.sdsu.edu!134.139.10.31!csulb.edu!news.service.uci.edu!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fc89c,6c31fbd9f931131d,start
X-Google-Attributes: gidfc89c,public
X-Google-Thread: 1025b4,6c31fbd9f931131d,start
X-Google-Attributes: gid1025b4,public
X-Google-ArrivalTime: 2001-01-06 21:54:53 PST
Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.gv.tsc.tdk.com!news.iac.net!news-out.cwix.com!newsfeed.cwix.com!news.maxwell.syr.edu!newshub.sdsu.edu!134.139.10.31!csulb.edu!news.service.uci.edu!not-for-mail
From: Charlie Zender <zender@uci.edu>
Newsgroups: comp.unix.programmer,gnu.misc.discuss
Subject: Example of gettext() program without autoconf
Date: Sat, 06 Jan 2001 21:48:45 -0800
Organization: University of California at Irvine
Lines: 64
Message-ID: <3A58033D.1040505@uci.edu>
NNTP-Posting-Host: dialin53a-36.ppp.uci.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
User-Agent: Mozilla/5.0 (X11; U; Linux 2.2.16-22 i686; en-US; m18) Gecko/20001205
X-Accept-Language: en