Author: suokko
Date: Sat Aug 23 18:08:20 2008
New Revision: 28882
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28882&view=rev
Log:
* Fixed dummylocales to work from svn tree
Modified:
trunk/CMakeLists.txt
trunk/Makefile.am
trunk/doc/man/wesnoth.6
trunk/src/game.cpp
trunk/src/language.cpp
trunk/src/tests/main.cpp
Modified: trunk/CMakeLists.txt
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/CMakeLists.txt?rev=28882&r1=28881&r2=28882&view=diff
==============================================================================
--- trunk/CMakeLists.txt (original)
+++ trunk/CMakeLists.txt Sat Aug 23 18:08:20 2008
@@ -179,7 +179,7 @@
add_custom_command(OUTPUT ${DUMMY_LOCALE_C_DIR}
COMMAND mkdir -p ${DUMMY_LOCALE_C_DIR}
- && echo | localedef --force ${DUMMY_LOCALE_C_DIR} 2>
/dev/null || true)
+ && echo | localedef -c ${DUMMY_LOCALE_C_DIR} 2> /dev/null
|| true)
file(GLOB_RECURSE LANGS RELATIVE ${CMAKE_SOURCE_DIR}/data/languages
data/languages/*.cfg)
Modified: trunk/Makefile.am
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/Makefile.am?rev=28882&r1=28881&r2=28882&view=diff
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Sat Aug 23 18:08:20 2008
@@ -96,7 +96,7 @@
@echo "Create dummy locales beneath the Wesnoth data directory"
$(mkdir_p) "$(DESTDIR)$(pkgdatadir)/locales"
if test -d "$(DESTDIR)$(pkgdatadir)/locales/C" ; then rm -r
"$(DESTDIR)$(pkgdatadir)/locales/C" ; fi
- echo | localedef --force "$(DESTDIR)$(pkgdatadir)/locales/C" 2>
/dev/null; \
+ echo | localedef -c "$(DESTDIR)$(pkgdatadir)/locales/C" 2> /dev/null; \
for loc in `ls data/languages/*.cfg | sed
-e's/data\/languages\/\(.*\)\.cfg/\1/'`; do \
loclnk="$(DESTDIR)$(pkgdatadir)/locales/$$loc"@wesnoth; \
if test -L "$$loclnk" ; then rm "$$loclnk" ; fi; \
Modified: trunk/doc/man/wesnoth.6
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/doc/man/wesnoth.6?rev=28882&r1=28881&r2=28882&view=diff
==============================================================================
--- trunk/doc/man/wesnoth.6 (original)
+++ trunk/doc/man/wesnoth.6 Sat Aug 23 18:08:20 2008
@@ -66,6 +66,10 @@
.RI ( infile )
that is in binary WML format into text WML format
.RI ( outfile ).
+.TP
+.B --dummylocales
+Use special dummy locales to switch to any language even if that language
+isn't installed to system
.TP
.B -f, --fullscreen
runs the game in full screen mode.
Modified: trunk/src/game.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/game.cpp?rev=28882&r1=28881&r2=28882&view=diff
==============================================================================
--- trunk/src/game.cpp (original)
+++ trunk/src/game.cpp Sat Aug 23 18:08:20 2008
@@ -373,6 +373,8 @@
std::cerr << "Setting path using " << val << std::endl;
if(val[0] == '/') {
game_config::path = val;
+ } else if (val == "." || val == "./") {
+ game_config::path = get_cwd();
} else {
game_config::path = get_cwd() + '/' + val;
}
Modified: trunk/src/language.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/language.cpp?rev=28882&r1=28881&r2=28882&view=diff
==============================================================================
--- trunk/src/language.cpp (original)
+++ trunk/src/language.cpp Sat Aug 23 18:08:20 2008
@@ -31,12 +31,15 @@
#include <cassert>
#include <cctype>
#include <cerrno>
+#include <cstring>
#include <clocale>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <stdexcept>
+#include <boost/scoped_array.hpp>
+
#ifdef _WIN32
//#include "locale.h"
#include <windows.h>
@@ -45,6 +48,7 @@
#define DBG_FS LOG_STREAM(debug, filesystem)
#define DBG_GENERAL LOG_STREAM(debug, general)
+#define LOG_GENERAL LOG_STREAM(debug, general)
#define WRN_GENERAL LOG_STREAM(debug, general)
@@ -181,10 +185,11 @@
return known_languages;
}
-static void wesnoth_setlocale(int category, std::string const &slocale,
+static void wesnoth_setlocale(int category, std::string slocale,
std::vector<std::string> const *alternates)
{
- char const *locale = slocale.c_str();
+ const char *locale = slocale.c_str();
+ std::string extra;
// FIXME: ideally we should check LANGUAGE and on first invocation
// use that value, so someone with es would get the game in Spanish
// instead of en_US the first time round
@@ -221,6 +226,7 @@
SetEnvironmentVariable("LC_ALL", win_locale.c_str());
if(category == LC_MESSAGES)
category = LC_ALL;
+ locale = win_locale.c_str();
#endif
#ifndef _WIN32
@@ -240,10 +246,14 @@
unsetenv("LOCPATH");
else
setenv("LOCPATH", locpath.c_str(), 1);
- else setenv("LOCPATH", (game_config::path +
"/locales").c_str(), 1);
+ else {
+ setenv("LOCPATH", (game_config::path +
"/locales").c_str(), 1);
+ DBG_GENERAL << "LOCPATH set to '" << (game_config::path
+ "/locales") << "'\n";
+ }
std::string xlocale;
if (!slocale.empty()) {
// dummy suffix to prevent locale aliasing from kicking
in
+ extra = "@wesnoth";
xlocale = slocale + "@wesnoth";
locale = xlocale.c_str();
}
@@ -251,28 +261,32 @@
#endif
char *res = NULL;
- #ifdef _WIN32
- char const *try_loc = win_locale.c_str();
- #else
- char const *try_loc = locale;
- #endif
+ std::string orig_locale;
+ orig_locale.assign(locale);
+
+ typedef boost::scoped_array<char> char_array;
+ char_array try_loc(new char[strlen(locale)+1]);
+ std::memcpy(try_loc.get(), locale, strlen(locale)+1);
std::vector<std::string>::const_iterator i;
if (alternates) i = alternates->begin();
while (true) {
- res = std::setlocale(category, try_loc);
+ res = std::setlocale(category, try_loc.get());
if (res) break;
- std::string utf8 = std::string(try_loc) + std::string(".utf-8");
+ std::string utf8 = orig_locale + std::string(".utf-8");
res = std::setlocale(category, utf8.c_str());
if (res) break;
- utf8 = std::string(try_loc) + std::string(".UTF-8");
+ utf8 = orig_locale + std::string(".UTF-8");
res = std::setlocale(category, utf8.c_str());
if (res) break;
if (!alternates) break;
if (i == alternates->end()) break;
- try_loc = i->c_str();
+ orig_locale = *i + extra;
+ try_loc.reset(new char[orig_locale.length()+1]);
+ orig_locale.copy(try_loc.get(), orig_locale.length());
+ try_loc[orig_locale.length()] = 0;
i++;
}
@@ -280,7 +294,7 @@
WRN_GENERAL << "WARNING: setlocale() failed for '"
<< locale << "'.\n";
else
- DBG_GENERAL << "set locale to '" << try_loc << "'\n";
+ LOG_GENERAL << "set locale to '" << (try_loc.get()) << "'
result: '" << res <<"'\n";
}
bool set_language(const language_def& locale)
Modified: trunk/src/tests/main.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/tests/main.cpp?rev=28882&r1=28881&r2=28882&view=diff
==============================================================================
--- trunk/src/tests/main.cpp (original)
+++ trunk/src/tests/main.cpp Sat Aug 23 18:08:20 2008
@@ -19,6 +19,7 @@
#include "SDL.h"
+#include "filesystem.hpp"
#include "game_config.hpp"
#include "game_errors.hpp"
#include "network.hpp"
@@ -50,7 +51,7 @@
wesnoth_global_fixture()
{
game_config::use_dummylocales = true;
- game_config::path = "./";
+ game_config::path = get_cwd();
// Initialize unit tests
SDL_Init(SDL_INIT_TIMER);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits