summaryrefslogtreecommitdiff
path: root/src/gettext.h
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-07-23 16:38:37 +0200
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2011-07-24 16:52:59 +0200
commitc578efb32b57b08275b9a0a2fd4a76b4e4b9e87d (patch)
tree6159b66d34e5294c715eaf53f9431dfbd9295d1e /src/gettext.h
parent5aa2679be7696862066edf617dc5a8261b7325ab (diff)
downloadminetest-c578efb32b57b08275b9a0a2fd4a76b4e4b9e87d.tar.gz
minetest-c578efb32b57b08275b9a0a2fd4a76b4e4b9e87d.tar.bz2
minetest-c578efb32b57b08275b9a0a2fd4a76b4e4b9e87d.zip
Refactor gettext init
Put the gettext init code in a macro and define it appropriately depending on whether gettext is actually available or not.
Diffstat (limited to 'src/gettext.h')
-rw-r--r--src/gettext.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/gettext.h b/src/gettext.h
index e74b4eb96..751b83774 100644
--- a/src/gettext.h
+++ b/src/gettext.h
@@ -1,21 +1,21 @@
-#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;