Mail Archives: djgpp/2012/03/17/10:38:49
> 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 -