2
votes

I will try to use gnu-gettext for localization of a semi-big software project, so now I'm trying to learn the basics. Problem is that I got stuck on a pretty fundamental function. When I try to extract the strings from the sourcecode using xgettext I get nothing. When dll's were missing it complained, and when a parameter is wrong it complains, but now it just silently returns without producing any pot-file or anything else.

So, my question is: Is there anybody out there recognizing this problem? Is there any way to make xgettext more verbose about what it is doing?

I have tried putting xgettext among the source-files and putting the sourcefiles in the gettext\bin directory, but to no avail.

I should mention that I am working on a Win7-machine and I use gettext-tools-dev_0.18.1.1-2_win32. I have installed MinGW.

My testcode locks like this:

#include <string>
#include <stdio.h>
#include <stdlib.h>
#include "libintl.h"
#include "locale.h"
#include "helper.h"

#define _(String) gettext(String)
#define N_(String) String
//#define textdomain(Domain)
//#define bindtextdomain(Package, Directory)

int main(void)
{
  printf( "setlocale returns %s\n", setlocale( LC_ALL, "" ) );

  bindtextdomain( "hello", "locale" );
  textdomain( "hello" ); 

  int a = 1;
  int b = 2;

  /// First string
  printf( _( "Hello, world!\n" ) );

  std::string multiline =
    /* Another string */
    _( "This is a " \
       "multi line string." );
  // A string that contains another
  printf( _( "A string: %s\n" ), multiline.c_str() );
  printf( N_( "An untranslatable string!\n" ));
  int foo = 42;
  /// Playing with positions; int before string in original...
  printf( _( "int: %1$d, string: %2$s\n" ), foo, _( "Fubar" )); 
  printf( _( "%1$s %2$s\n" ), Helper::String1().c_str(), Helper::String2().c_str() );
  exit(0);
}

If somebody could help me out on this, I would be thankful. /Robert

1

1 Answers

3
votes

Ok, I solved it. I somehow thought that xgettext would understand the redefinition:

#define _(String) gettext(String)

Well, obviously it didn't and when I read the manual carefully it kind of said that as well.

So when I added -k_ to the xgettext options it all worked.

/Robert