# Gettext problem (solved)

**URL:** https://discourse.cataclysmdda.org/t/gettext-problem-solved/2319
**Category:** The Toolbox
**Created:** [July 20, 2013, 5:37pm UTC](https://discourse.cataclysmdda.org/t/gettext-problem-solved/2319 "2013-07-20T17:37:20Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![utunnels](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/utunnels/32/81_2.png) [@utunnels](https://discourse.cataclysmdda.org/u/utunnels)
#### Post date: [July 20, 2013, 5:37pm UTC](https://discourse.cataclysmdda.org/t/gettext-problem-solved/2319/1 "2013-07-20T17:37:20Z")

</div>

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`

---

<div class="post-metadata">

### Author: ![utunnels](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.cataclysmdda.org/utunnels/32/81_2.png) [@utunnels](https://discourse.cataclysmdda.org/u/utunnels)
#### Post date: [July 21, 2013, 10:16am UTC](https://discourse.cataclysmdda.org/t/gettext-problem-solved/2319/2 "2013-07-21T10:16:50Z")

</div>

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