Broken dummylocales runtime configuration implementation. installation fails
This commit is contained in:
parent
ebc01fba94
commit
a5ed42c1dd
10 changed files with 99 additions and 71 deletions
|
@ -173,36 +173,37 @@ add_subdirectory(src)
|
|||
|
||||
if(ENABLE_DUMMY_LOCALES)
|
||||
add_definitions(-DUSE_DUMMYLOCALES)
|
||||
set(DUMMY_LOCALE_C_DIR ${CMAKE_SOURCE_DIR}/locales/C)
|
||||
|
||||
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)
|
||||
|
||||
file(GLOB_RECURSE LANGS RELATIVE ${CMAKE_SOURCE_DIR}/data/languages data/languages/*.cfg)
|
||||
|
||||
set(DUMMY_LOCALES)
|
||||
foreach(LANGFILE ${LANGS})
|
||||
string(REGEX REPLACE "(.*)\\.cfg" "\\1" LANG ${LANGFILE})
|
||||
if(NOT LANG STREQUAL "C")
|
||||
set(DUMMY_LOCALE_DIR ${CMAKE_SOURCE_DIR}/locales/${LANG})
|
||||
add_custom_command(OUTPUT ${DUMMY_LOCALE_DIR}
|
||||
COMMAND ln -s
|
||||
ARGS ${DUMMY_LOCALE_C_DIR} ${DUMMY_LOCALE_DIR}
|
||||
DEPENDS ${DUMMY_LOCALE_C_DIR})
|
||||
|
||||
set(DUMMY_LOCALES ${DUMMY_LOCALES} ${DUMMY_LOCALE_DIR})
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
add_custom_target(dummy-locales ALL DEPENDS ${DUMMY_LOCALES})
|
||||
|
||||
# this is a workaround for a bug in 2.4-7
|
||||
file(MAKE_DIRECTORY locales)
|
||||
install(DIRECTORY locales DESTINATION ${DATADIR} )
|
||||
|
||||
endif()
|
||||
|
||||
set(DUMMY_LOCALE_C_DIR ${CMAKE_SOURCE_DIR}/locales/C)
|
||||
|
||||
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)
|
||||
|
||||
file(GLOB_RECURSE LANGS RELATIVE ${CMAKE_SOURCE_DIR}/data/languages data/languages/*.cfg)
|
||||
|
||||
set(DUMMY_LOCALES)
|
||||
foreach(LANGFILE ${LANGS})
|
||||
string(REGEX REPLACE "(.*)\\.cfg" "\\1" LANG ${LANGFILE})
|
||||
if(NOT LANG STREQUAL "C")
|
||||
set(DUMMY_LOCALE_DIR ${CMAKE_SOURCE_DIR}/locales/${LANG})
|
||||
add_custom_command(OUTPUT ${DUMMY_LOCALE_DIR}
|
||||
COMMAND ln -s
|
||||
ARGS ${DUMMY_LOCALE_C_DIR} ${DUMMY_LOCALE_DIR}
|
||||
DEPENDS ${DUMMY_LOCALE_C_DIR})
|
||||
|
||||
set(DUMMY_LOCALES ${DUMMY_LOCALES} ${DUMMY_LOCALE_DIR})
|
||||
endif()
|
||||
|
||||
endforeach()
|
||||
add_custom_target(dummy-locales ALL DEPENDS ${DUMMY_LOCALES})
|
||||
|
||||
# this is a workaround for a bug in 2.4-7
|
||||
file(MAKE_DIRECTORY locales)
|
||||
install(DIRECTORY locales DESTINATION ${DATADIR} )
|
||||
|
||||
|
||||
#
|
||||
# shrink images for tinygui
|
||||
#
|
||||
|
|
|
@ -92,7 +92,7 @@ if INSTALLDATA
|
|||
echo $(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; \
|
||||
$(INSTALL_DATA) "$$d$$p" "$(DESTDIR)$(docdir)/$$f"; cd ..; \
|
||||
done
|
||||
if DUMMYLOCALES
|
||||
#if DUMMYLOCALES
|
||||
@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
|
||||
|
@ -102,7 +102,7 @@ if DUMMYLOCALES
|
|||
if test -L "$$loclnk" ; then rm "$$loclnk" ; fi; \
|
||||
ln -s C "$$loclnk"; done; \
|
||||
true
|
||||
endif
|
||||
#endif
|
||||
if TINYGUI
|
||||
@echo "Shrink installed images by a factor of two."
|
||||
(cd $(top_srcdir) && find data/core/images data/campaigns images \( $(findfilterflags) -a -name '*.png' -and -not -name 'bar-energy-tinygui.png' -print \) ) | while read p; do \
|
||||
|
|
20
SConstruct
20
SConstruct
|
@ -293,10 +293,18 @@ if env["PLATFORM"] == 'win32':
|
|||
if env["PLATFORM"] == 'darwin': # Mac OS X
|
||||
env.Append(FRAMEWORKS = "Carbon") # Carbon GUI
|
||||
|
||||
try:
|
||||
env["svnrev"] = Popen(Split("svnversion -n ."), stdout=PIPE).communicate()[0]
|
||||
except:
|
||||
env["svnrev"] = ""
|
||||
if os.path.exists('.git'):
|
||||
import re
|
||||
p = re.compile('Revision: ([0-9]+)');
|
||||
try:
|
||||
env["svnrev"] = p.search(Popen(Split("git-svn info"), stdout=PIPE).communicate()[0]).group(1)
|
||||
except:
|
||||
env["svnrev"] = ""
|
||||
else:
|
||||
try:
|
||||
env["svnrev"] = Popen(Split("svnversion -n ."), stdout=PIPE).communicate()[0]
|
||||
except:
|
||||
env["svnrev"] = ""
|
||||
|
||||
Export(Split("env have_client_prereqs have_server_prereqs have_test_prereqs"))
|
||||
SConscript(dirs = Split("po doc packaging/windows"))
|
||||
|
@ -342,7 +350,7 @@ env.Clean(all, 'TAGS')
|
|||
# Dummy locales
|
||||
#
|
||||
|
||||
if env["dummy_locales"]:
|
||||
if env["nls"]:
|
||||
env.Command(Dir("locales/C"), [], "-mkdir -p locales;echo | localedef --force \"$TARGET\" 2> /dev/null")
|
||||
language_cfg_re = re.compile(r"data/languages/(.*)\.cfg")
|
||||
language_cfgs = glob("data/languages/*.cfg")
|
||||
|
@ -373,7 +381,7 @@ docdir = env['docdir']
|
|||
installable_subs = Split('data fonts icons images sounds')
|
||||
if env['nls']:
|
||||
installable_subs.append("translations")
|
||||
if env['dummy_locales']:
|
||||
if env['nls']:
|
||||
installable_subs.append("locales")
|
||||
fifodir = env['fifodir']
|
||||
mandir = env["mandir"]
|
||||
|
|
|
@ -66,6 +66,7 @@ libwesnoth_sources = Split("""
|
|||
hotkeys.cpp
|
||||
image.cpp
|
||||
key.cpp
|
||||
language.cpp
|
||||
loadscreen.cpp
|
||||
map_create.cpp
|
||||
map_label.cpp
|
||||
|
@ -104,7 +105,6 @@ libwesnoth_sources = Split("""
|
|||
""")
|
||||
libwesnoth_sources.extend([
|
||||
env.Object("font.cpp", EXTRA_DEFINE = env['fribidi'] and "HAVE_FRIBIDI" or None),
|
||||
env.Object("language.cpp", EXTRA_DEFINE = env['dummy_locales'] and "USE_DUMMYLOCALES" or None)
|
||||
])
|
||||
|
||||
libwesnoth = env.Library("wesnoth", libwesnoth_sources)
|
||||
|
@ -370,6 +370,8 @@ if env["svnrev"] != "" and env["svnrev"] != "exported":
|
|||
"Generating revision.hpp..."
|
||||
))
|
||||
game_config_env.Append(CPPDEFINES = 'HAVE_REVISION')
|
||||
if env['dummy_locales']:
|
||||
game_config_env.Append(CPPDEFINES = 'USE_DUMMYLOCALES')
|
||||
|
||||
sources = []
|
||||
if "TAGS" in COMMAND_LINE_TARGETS:
|
||||
|
|
|
@ -363,6 +363,8 @@ game_controller::game_controller(int argc, char** argv) :
|
|||
} else if(val == "-e" || val == "--editor") {
|
||||
jump_to_editor_ = true;
|
||||
#endif
|
||||
} else if(val == "--dummylocales") {
|
||||
game_config::use_dummylocales = true;
|
||||
} else if(val[0] == '-') {
|
||||
std::cerr << "unknown option: " << val << std::endl;
|
||||
throw config::error("unknown option");
|
||||
|
@ -1957,6 +1959,7 @@ static int process_command_args(int argc, char** argv) {
|
|||
<< " by id.\n"
|
||||
<< " --turns=value sets the number of turns. The default is \"50\".\n"
|
||||
<< " --exit-at-end exit Wesnoth at end of scenario.\n"
|
||||
<< " --dummylocales Enable dummylocales for switching to non-system locale.\n"
|
||||
<< " --new-widgets there is a new WIP widget toolkit this switch enables the new toolkit\n"
|
||||
<< " (VERY EXPERIMENTAL don't file bug reports since most are known).\n"
|
||||
;
|
||||
|
|
|
@ -53,6 +53,12 @@ namespace game_config
|
|||
std::string wesnothd_name;
|
||||
bool debug = false, editor = false, ignore_replay_errors = false, mp_debug = false, exit_at_end = false, no_delay = false, small_gui = false, disable_autosave = false;
|
||||
|
||||
#ifdef USE_DUMMYLOCALES
|
||||
bool use_dummylocales = true;
|
||||
#else
|
||||
bool use_dummylocales = false;
|
||||
#endif
|
||||
|
||||
std::string game_icon = "wesnoth-icon.png", game_title, game_logo, title_music, lobby_music;
|
||||
int title_logo_x = 0, title_logo_y = 0, title_buttons_x = 0, title_buttons_y = 0, title_buttons_padding = 0,
|
||||
title_tip_x = 0, title_tip_width = 0, title_tip_padding = 0;
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace game_config
|
|||
|
||||
extern bool debug, editor, ignore_replay_errors, mp_debug, exit_at_end, no_delay, small_gui, disable_autosave;
|
||||
|
||||
extern bool use_dummylocales;
|
||||
|
||||
extern std::string path;
|
||||
|
||||
struct server_info {
|
||||
|
|
|
@ -104,21 +104,22 @@ bool language_def::operator== (const language_def& a) const
|
|||
|
||||
bool language_def::available() const
|
||||
{
|
||||
#ifdef USE_DUMMYLOCALES
|
||||
// Dummy has every language available.
|
||||
return true;
|
||||
#else
|
||||
if(has_language(localename)) {
|
||||
if (game_config::use_dummylocales)
|
||||
{
|
||||
// Dummy has every language available.
|
||||
return true;
|
||||
} else {
|
||||
foreach(const std::string& lang, alternates) {
|
||||
if(has_language(lang)) {
|
||||
return true;
|
||||
}else{
|
||||
if(has_language(localename)) {
|
||||
return true;
|
||||
} else {
|
||||
foreach(const std::string& lang, alternates) {
|
||||
if(has_language(lang)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
symbol_table string_table;
|
||||
|
@ -218,28 +219,29 @@ static void wesnoth_setlocale(int category, std::string const &slocale,
|
|||
category = LC_ALL;
|
||||
#endif
|
||||
|
||||
#ifdef USE_DUMMYLOCALES
|
||||
static enum { UNINIT, NONE, PRESENT } status = UNINIT;
|
||||
static std::string locpath;
|
||||
if (status == UNINIT) {
|
||||
if (char const *p = getenv("LOCPATH")) {
|
||||
locpath = p;
|
||||
status = PRESENT;
|
||||
} else status = NONE;
|
||||
if (game_config::use_dummylocales)
|
||||
{
|
||||
static enum { UNINIT, NONE, PRESENT } status = UNINIT;
|
||||
static std::string locpath;
|
||||
if (status == UNINIT) {
|
||||
if (char const *p = getenv("LOCPATH")) {
|
||||
locpath = p;
|
||||
status = PRESENT;
|
||||
} else status = NONE;
|
||||
}
|
||||
if (slocale.empty())
|
||||
if (status == NONE)
|
||||
unsetenv("LOCPATH");
|
||||
else
|
||||
setenv("LOCPATH", locpath.c_str(), 1);
|
||||
else setenv("LOCPATH", (game_config::path + "/locales").c_str(), 1);
|
||||
std::string xlocale;
|
||||
if (!slocale.empty()) {
|
||||
// dummy suffix to prevent locale aliasing from kicking in
|
||||
xlocale = slocale + "@wesnoth";
|
||||
locale = xlocale.c_str();
|
||||
}
|
||||
}
|
||||
if (slocale.empty())
|
||||
if (status == NONE)
|
||||
unsetenv("LOCPATH");
|
||||
else
|
||||
setenv("LOCPATH", locpath.c_str(), 1);
|
||||
else setenv("LOCPATH", (game_config::path + "/locales").c_str(), 1);
|
||||
std::string xlocale;
|
||||
if (!slocale.empty()) {
|
||||
// dummy suffix to prevent locale aliasing from kicking in
|
||||
xlocale = slocale + "@wesnoth";
|
||||
locale = xlocale.c_str();
|
||||
}
|
||||
#endif
|
||||
|
||||
char *res = NULL;
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -19,10 +19,12 @@
|
|||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "game_config.hpp"
|
||||
#include "game_errors.hpp"
|
||||
#include "network.hpp"
|
||||
#include "config.hpp"
|
||||
#include "log.hpp"
|
||||
#include "language.hpp"
|
||||
|
||||
#include "tests/utils/fake_display.hpp"
|
||||
/**
|
||||
|
@ -47,12 +49,13 @@ static void exception_translator_game(const game::error& e)
|
|||
struct wesnoth_global_fixture {
|
||||
wesnoth_global_fixture()
|
||||
{
|
||||
game_config::use_dummylocales = true;
|
||||
|
||||
// Initialize unit tests
|
||||
SDL_Init(SDL_INIT_TIMER);
|
||||
test_utils::get_fake_display();
|
||||
|
||||
// lg::set_log_domain_severity("all",3);
|
||||
lg::set_log_domain_severity("all",3);
|
||||
|
||||
// Set more report as default
|
||||
if (boost::unit_test::runtime_config::log_level() == boost::unit_test::invalid_log_level)
|
||||
|
@ -63,6 +66,7 @@ struct wesnoth_global_fixture {
|
|||
boost::unit_test::unit_test_monitor.register_exception_translator<game::error>(&exception_translator_game);
|
||||
boost::unit_test::unit_test_monitor.register_exception_translator<network::error>(&exception_translator_network);
|
||||
boost::unit_test::unit_test_monitor.register_exception_translator<config::error>(&exception_translator_config);
|
||||
load_language_list();
|
||||
}
|
||||
~wesnoth_global_fixture()
|
||||
{
|
||||
|
|
|
@ -146,7 +146,7 @@ BOOST_AUTO_TEST_CASE( test_translation_reload )
|
|||
std::vector<language_def>::const_iterator German = std::find_if(languages.begin(),
|
||||
languages.end(),
|
||||
match_german); // Using German because the most active translation
|
||||
BOOST_REQUIRE_MESSAGE(German != languages.end(), "German translation not found");
|
||||
BOOST_REQUIRE_MESSAGE(German != languages.end() && German->available(), "German translation not found");
|
||||
::set_language(*German);
|
||||
cache.reload_translations();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue