Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 17825

GNU gettext not working

$
0
0
Hi! Recently, I was trying to get GNU gettext to work, and I encountered a weird problem: it all translates just fine, but only to the system language. No matter what I pass to setlocale, it doesn't change the language. My file hierarchy looks basically like that: Project folder -> locale -> en_US -> LC_MESSAGES -> domain.mo & domain.po pl_PL -> LC_MESSAGES -> domain_pl.mo & domain_pl.po Here's my code: #include <iostream> #include <libintl.h> #include <locale> #include <string> using namespace std; void selectLangDomain(const char* domain, const char* language) { setlocale(LC_MESSAGES, language); bindtextdomain(domain, "./locale"); textdomain(domain); cout << gettext("Hello world!") << endl; cout << gettext("Another message.") << endl; } int main() { selectLangDomain("domain_pl", "pl_PL"); selectLangDomain("domain", "en_US"); return 0; }

Viewing all articles
Browse latest Browse all 17825

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>