|
From: Yoda-JM <yo...@us...> - 2010-05-17 21:30:19
|
Module: performous
Branch: master
Commit: b1c421f660380e32c50f5fc18dd3847c36fd3a89
Author: Vincent Le Ligeour <yo...@us...>
Date: Mon May 17 23:29:50 2010 +0200
Moved i18n specific code out of main.cc
---
game/i18n.hh | 23 +++++++++++++++++++++++
game/main.cc | 17 ++---------------
2 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/game/i18n.hh b/game/i18n.hh
index 27543bc..941230e 100644
--- a/game/i18n.hh
+++ b/game/i18n.hh
@@ -9,3 +9,26 @@
#define _(x) (x)
#endif
+class Gettext {
+ public:
+ Gettext(const char *package) {
+#ifdef USE_GETTEXT
+ // initialize gettext
+#ifdef _MSC_VER
+ setlocale(LC_ALL, "");//only untill we don't have a better solution. This because LC_MESSAGES cause crash under Visual Studio
+#else
+ setlocale (LC_MESSAGES, "");
+#endif
+ bindtextdomain (package, getLocaleDir().string().c_str());
+ textdomain (package);
+ bind_textdomain_codeset (package, "UTF-8");
+#endif
+ };
+ static bool enabled() {
+ #ifdef USE_GETTEXT
+ return true;
+ #else
+ return false;
+ #endif
+ }
+};
diff --git a/game/main.cc b/game/main.cc
index d3a432a..91aed77 100644
--- a/game/main.cc
+++ b/game/main.cc
@@ -282,17 +282,8 @@ template <typename Container> void confOverride(Container const& c, std::string
void outputOptionalFeatureStatus();
int main(int argc, char** argv) try {
-#ifdef USE_GETTEXT
// initialize gettext
-#ifdef _MSC_VER
- setlocale(LC_ALL, "");//only untill we don't have a better solution. This because LC_MESSAGES cause crash under Visual Studio
-#else
- setlocale (LC_MESSAGES, "");
-#endif
- bindtextdomain (PACKAGE, getLocaleDir().string().c_str());
- textdomain (PACKAGE);
- bind_textdomain_codeset (PACKAGE, "UTF-8");
-#endif
+ Gettext gettext(PACKAGE);
std::cout << PACKAGE " " VERSION << std::endl;
signalSetup();
@@ -410,11 +401,7 @@ int main(int argc, char** argv) try {
void outputOptionalFeatureStatus() {
std::cout << " Internationalization: " <<
- #ifdef USE_GETTEXT
- "Enabled"
- #else
- "Disabled"
- #endif
+ (Gettext::enabled() ? "Enabled" : "Disabled")
<< std::endl << " MIDI I/O: " <<
#ifdef USE_PORTMIDI
"Enabled"
|