[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bindtextdomain, textdomain, and gettext not getting called.

From: David Bruce
Subject: bindtextdomain, textdomain, and gettext not getting called.
Date: Wed, 7 Nov 2007 21:53:40 +0000
User-agent: KMail/1.9.7


I'm trying to get my program's i18n working, and it seems it never calls 
gettext.  I've been referring to the FAQ and the manual.  Here's my program's 

#include <stdio.h>
#include <stdlib.h>
#include <locale.h>
#include "gettext.h"
#include "tuxmath.h"
#include "setup.h"
#include "game.h"
#include "options.h"
#include "credits.h"

#include "titlescreen.h"

/* global data: */

int main(int argc, char * argv[])
#ifndef MACOSX
#ifndef WIN32
  char* loc = setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  bind_textdomain_codeset(PACKAGE, "UTF-8");

  /* debugging: */
  fprintf(stderr, "locale is: %s\n", loc);
  fprintf(stderr, "N_('Help') is: %s\n", N_("Help"));
  fprintf(stderr, "_('Help') is: %s\n", _("Help"));
  fprintf(stderr, "gettext('Help') is: %s\n", gettext("Help"));


  /* Just return instead of running actual game while testing gettext: */

//  setup(argc, argv);
//  atexit(cleanup);  // register it so we clean up even if there is a crash
//  TitleScreen();
  return 0;

The gettext-related includes and #defines are in "tuxmath.h", the relevant 
part of which is:

#ifndef TUXMATH_H
#define TUXMATH_H

// Translation stuff:
#ifdef MACOSX
#define N_(String) String
#define _(String) String
#ifdef WIN32
#define N_(String) String
#define _(String) String
#include "gettext.h"
#include <locale.h>
#define _(String) gettext (String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)

When I build the program, gcc warns about "statements with no effect"

../../trunk/src/tuxmath.c: In function ‘main’:
../../trunk/src/tuxmath.c:43: warning: statement with no effect
../../trunk/src/tuxmath.c:44: warning: statement with no effect
../../trunk/src/tuxmath.c:45: warning: statement with no effect

( referring to the lines in main() with bindtextdomain(), 
bind_textdomain_codeset(), and textdomain() ).

Running under ltrace I get:

address@hidden:~/tux4kids/tuxmath/build$ ltrace tuxmath
__libc_start_main(0x402690, 1, 0x7ffff5ecc5a8, 0x416b90, 0x416b80 
<unfinished ...>
setlocale(6, "")                                                                
= "nn_NO.UTF-8"
fprintf(0x2b72b5abe880, "locale is: %s\n", "nn_NO.UTF-8"locale is: nn_NO.UTF-8
)                                                     = 23
fprintf(0x2b72b5abe880, "N_('Help') is: %s\n", "Help"N_('Help') is: Help
)                                                        = 20
fprintf(0x2b72b5abe880, "_('Help') is: %s\n", "Help"_('Help') is: Help
)                                                         = 19
fprintf(0x2b72b5abe880, "gettext('Help') is: %s\n", "Help"gettext('Help') is: 
)                                                   = 25


The gettext FAQ says:
>If gettext/dgettext/dcgettext is not called at all, the possible cause might 
>be that some autoconf or Makefile macrology has turned off 
>internationalization entirely (like the --disable-nls configuration option 
>usually does).
but I couldn't find any such disabling in my configure.ac or Makefile.am's.

Thanks for any help!

David Bruce

reply via email to

[Prev in Thread] Current Thread [Next in Thread]