Gettext problem (solved)

  1. Strings in header sometimes can’t be translated
    Because textdomain is called in main(), code outside of main are executed before that so gettext doesn’t know which mo file it should load.
    An example: facdata.h

Possible solution: Move then to a cpp file and initialize the array in a function.
Another solution (which proves the problem):
Add several lines in facdata.h, before those arrays.

const char* dummy_locale = setlocale(LC_ALL, ""); const char* dummy_domain_path = bindtextdomain("cataclysm-dda", "lang/mo"); const char* dummy_codeset = bind_textdomain_codeset("cataclysm-dda", "UTF-8"); const char* dummy_domain = textdomain("cataclysm-dda");

  1. sprintf doesn’t support format string like %1$s %2$s
    I’m using MINGW compiler I can still use libintl_sprintf instead, but I know it is not the proper way to fix this problem. LOL

I found these in libintl.h

#if !(defined sprintf && defined _GL_STDIO_H) /* don't override gnulib */ #undef sprintf #define sprintf libintl_sprintf extern int sprintf (char *, const char *, ...); #endif

Maybe I should close this topic. LOL
The sprintf bug was fixed mysteriously after I included explicitly.