delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2012/03/17/10:38:49

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Recipient: djgpp AT delorie DOT com
Date: Sat, 17 Mar 2012 16:38:05 +0200
From: Eli Zaretskii <eliz AT gnu DOT org>
Subject: Re: GNU gettext
In-reply-to: <bba88497-fdf0-4276-b6fa-7e34e4bc11cd@d17g2000vba.googlegroups.com>
X-012-Sender: halo1 AT inter DOT net DOT il
To: djgpp AT delorie DOT com
Message-id: <83obrv2sz6.fsf@gnu.org>
References: <bba88497-fdf0-4276-b6fa-7e34e4bc11cd AT d17g2000vba DOT googlegroups DOT com>
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> From: Georg <dosusb AT googlemail DOT com>
> Date: Sat, 17 Mar 2012 03:48:00 -0700 (PDT)
> 
> I am porting a program from Linux to DOS. This then uses my FLTK for
> DOS port which allows to display UTF8 characters using an ISO10646
> truetype font.
> 
> The linux program uses "gettext" to allow to display the menu items in
> different languages. There is a "po" directory with files for these
> different languages.
> 
> In "main.cpp" there are the following commands:
> 
> // GNU gettext initialization
> setlocale(LC_MESSAGES, "");
> bindtextdomain(PACKAGE, LOCALEDIR);
> textdomain(PACKAGE);
> 
> Within the other program files which define the menus there is
> defined:
> 
> #define _(String) gettext((String))
> 
> this refers to e.g. this command:
> fl_alert(_("Cannot open file..."));
> 
> DJGPP/libintl compiles the programs fine but I am not sure what it
> actually does when executing the commands mentioned above.

It calls the `gettext' function (through the _ macro), which looks up
the string "Cannot open file..." in the message catalog for the
current language, and returns its translation.  So fl_alert will
display the translated message.

> Can I use the DJGPP version of "gettext" in my situation and if yes,
> how?

It depends on how you did the font stuff.  gettext assumes that if you
send an iso8859-1 code to the screen, the corresponding iso8859-1
character is displayed (and the same with any other character set).

> If I get "gettext" to work, can it be used with a command line option
> or a menu in the program to allow to select the desired language?

You will need to call setlocale and bindtextdomain based on those
options, then it should work.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019