[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src language.cpp
From: |
Yann Dirson |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src language.cpp |
Date: |
Wed, 08 Sep 2004 16:00:46 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Yann Dirson <address@hidden> 04/09/08 19:55:46
Modified files:
src : language.cpp
Log message:
work around BeOS' gettext implementation (adapted patch from
ahwayakchih)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/language.cpp.diff?tr1=1.39&tr2=1.40&r1=text&r2=text
Patches:
Index: wesnoth/src/language.cpp
diff -u wesnoth/src/language.cpp:1.39 wesnoth/src/language.cpp:1.40
--- wesnoth/src/language.cpp:1.39 Tue Sep 7 19:52:19 2004
+++ wesnoth/src/language.cpp Wed Sep 8 19:55:46 2004
@@ -1,4 +1,4 @@
-/* $Id: language.cpp,v 1.39 2004/09/07 19:52:19 silene Exp $ */
+/* $Id: language.cpp,v 1.40 2004/09/08 19:55:46 ydirson Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -20,6 +20,7 @@
#include <cstdlib>
#include <cstring>
#include <iostream>
+#include <sstream>
namespace {
language_def current_language;
@@ -103,6 +104,19 @@
return res;
}
+// This solely exist to work around problems in the BeOS port.
+// I don't put an #ifdef yet to see first whether it fixes other
+// problems, like the MacOS-X ones.
+char* wesnoth_setlocale(int category, const char *locale)
+{
+ if (setenv ("LANG", locale, 1) == -1)
+ std::cerr << "setenv LANG failed: " << strerror(errno);
+ if (setenv ("LC_ALL", locale, 1) == -1)
+ std::cerr << "setenv LC_ALL failed: " << strerror(errno);
+
+ return setlocale (category, locale);
+}
+
namespace {
bool internal_set_language(const language_def& locale, config& cfg)
{
@@ -113,7 +127,7 @@
current_language.language = (**i)["language"];
current_language.localename = (**i)["id"];
- setlocale (LC_MESSAGES, locale.localename.c_str());
+ wesnoth_setlocale (LC_MESSAGES,
locale.localename.c_str());
return true;
}
@@ -134,7 +148,7 @@
config cfg;
current_language = locale;
- setlocale (LC_MESSAGES, locale.localename.c_str());
+ wesnoth_setlocale (LC_MESSAGES, locale.localename.c_str());
font::set_font();
// fill string_table (should be moved somwhere else some day)
@@ -167,7 +181,7 @@
const std::string& prefs_locale = preferences::locale();
if(prefs_locale.empty() == false) {
- char* setlocaleres = setlocale (LC_MESSAGES,
prefs_locale.c_str());
+ char* setlocaleres = wesnoth_setlocale (LC_MESSAGES,
prefs_locale.c_str());
if(setlocaleres == NULL)
std::cerr << "call to setlocale() failed for " <<
prefs_locale.c_str() << "\n";
for(int i = 0; known_languages[i].language[0] != '\0'; i++) {
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Guillaume Melquiond, 2004/09/07
- [Wesnoth-cvs-commits] wesnoth/src language.cpp,
Yann Dirson <=
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Yann Dirson, 2004/09/09
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Yann Dirson, 2004/09/09
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Yann Dirson, 2004/09/09
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Guillaume Melquiond, 2004/09/11
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Yann Dirson, 2004/09/11
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Yann Dirson, 2004/09/11
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Yann Dirson, 2004/09/19
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Isaac Clerencia, 2004/09/19
- [Wesnoth-cvs-commits] wesnoth/src language.cpp, Alfredo Beaumont, 2004/09/19