forked from Mirrorlandia_minetest/minetest
Refactor gettext init
Put the gettext init code in a macro and define it appropriately depending on whether gettext is actually available or not.
This commit is contained in:
parent
5aa2679be7
commit
c578efb32b
@ -1,21 +1,21 @@
|
|||||||
#ifdef GETTEXT_FOUND
|
#if defined(GETTEXT_FOUND) && defined(USE_GETTEXT)
|
||||||
#ifdef USE_GETTEXT
|
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#else
|
#else
|
||||||
#define gettext(String) String
|
#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
|
#endif
|
||||||
|
|
||||||
#define _(String) gettext(String)
|
#define _(String) gettext(String)
|
||||||
#define gettext_noop(String) String
|
#define gettext_noop(String) String
|
||||||
#define N_(String) gettext_noop (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)
|
inline wchar_t* chartowchar_t(const char *str)
|
||||||
{
|
{
|
||||||
size_t l = strlen(str)+1;
|
size_t l = strlen(str)+1;
|
||||||
|
@ -1132,11 +1132,7 @@ int main(int argc, char *argv[])
|
|||||||
// Create user data directory
|
// Create user data directory
|
||||||
fs::CreateDir(porting::path_userdata);
|
fs::CreateDir(porting::path_userdata);
|
||||||
|
|
||||||
#ifdef LC_MESSAGES
|
init_gettext((porting::path_userdata+"/locale").c_str());
|
||||||
setlocale(LC_MESSAGES, "");
|
|
||||||
bindtextdomain(PROJECT_NAME, (porting::path_userdata+"/locale").c_str());
|
|
||||||
textdomain(PROJECT_NAME);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Initialize debug streams
|
// Initialize debug streams
|
||||||
#ifdef RUN_IN_PLACE
|
#ifdef RUN_IN_PLACE
|
||||||
|
Loading…
Reference in New Issue
Block a user