Skip to content
Snippets Groups Projects
Commit c578efb3 authored by Giuseppe Bilotta's avatar Giuseppe Bilotta
Browse files

Refactor gettext init

Put the gettext init code in a macro and define it appropriately
depending on whether gettext is actually available or not.
parent 5aa2679b
No related branches found
No related tags found
No related merge requests found
#ifdef GETTEXT_FOUND
#ifdef USE_GETTEXT
#if defined(GETTEXT_FOUND) && defined(USE_GETTEXT)
#include <libintl.h>
#else
#define gettext(String) String
#define bindtextdomain(domain, dir) /* */
#define textdomain(domain) /* */
#endif
#else
#define gettext(String) String
#define bindtextdomain(domain, dir) /* */
#define textdomain(domain) /* */
#endif
#define _(String) gettext(String)
#define gettext_noop(String) String
#define N_(String) gettext_noop (String)
inline void init_gettext(const char *path) {
#if USE_GETTEXT
setlocale(LC_MESSAGES, "");
bindtextdomain(PROJECT_NAME, path);
textdomain(PROJECT_NAME);
#endif
}
inline wchar_t* chartowchar_t(const char *str)
{
size_t l = strlen(str)+1;
......
......@@ -1132,11 +1132,7 @@ int main(int argc, char *argv[])
// Create user data directory
fs::CreateDir(porting::path_userdata);
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
bindtextdomain(PROJECT_NAME, (porting::path_userdata+"/locale").c_str());
textdomain(PROJECT_NAME);
#endif
init_gettext((porting::path_userdata+"/locale").c_str());
// Initialize debug streams
#ifdef RUN_IN_PLACE
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment