Localized image states are now checked at runtime,
...so that fuzzy localized images are not used if present. This requires installing the l10n-track file as well.
This commit is contained in:
parent
ef3aa73d8d
commit
18dd3c5871
4 changed files with 35 additions and 2 deletions
|
@ -339,6 +339,9 @@ if(ENABLE_SERVER AND FIFO_DIR)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
# Index for checking states of localized images at runtime.
|
||||
install(FILES l10n-track DESTINATION ${DATADIR})
|
||||
|
||||
#
|
||||
# uninstall
|
||||
#
|
||||
|
|
|
@ -8,7 +8,7 @@ bin_SCRIPTS =
|
|||
findfilterflags=! \( -name .svn -prune -o -name ".\#*" -o -name "*~" -o -name "*bak" -o -name 'Makefile' -o -name '*Makefile' -o -type d -o -regex "data/test/*" \)
|
||||
|
||||
# List all datafiles, ignoring junk
|
||||
finddata=(cd $(top_srcdir) && find data fonts icons images sounds $(findfilterflags) -print )
|
||||
finddata=(cd $(top_srcdir) && find data fonts icons images sounds l10n-track $(findfilterflags) -print )
|
||||
# List all data subdirectories
|
||||
finddatadirs=(cd $(top_srcdir) && find data fonts icons images sounds -type d \! \( -name .svn -prune \) -print )
|
||||
# List non-installable utility files
|
||||
|
|
|
@ -534,6 +534,7 @@ env.InstallData("datadir", "wesnoth", map(Dir, installable_subs))
|
|||
env.InstallData("docdir", "wesnoth", [Glob("doc/manual/*.html"), Dir("doc/manual/styles"), Dir("doc/manual/images")])
|
||||
if env["nls"]:
|
||||
env.InstallData("localedir", "wesnoth", Dir("translations"))
|
||||
env.InstallData("datadir", "wesnoth", "l10n-track")
|
||||
InstallManpages(env, "wesnoth")
|
||||
if have_client_prereqs and have_X and env["desktop_entry"]:
|
||||
if sys.platform == "darwin":
|
||||
|
|
|
@ -316,6 +316,35 @@ size_t hash_value(const locator::value& val) {
|
|||
return hash;
|
||||
}
|
||||
|
||||
// Check if localized file is uptodate according to l10n track index.
|
||||
static std::set<std::string> uptodate_localized_files;
|
||||
static bool localized_file_uptodate (const std::string& loc_file)
|
||||
{
|
||||
if (uptodate_localized_files.size() == 0) {
|
||||
// First call, parse track index to collect uptodate files by path.
|
||||
std::string fsep = "\xC2\xA6"; // UTF-8 for "broken bar"
|
||||
std::string trackpath = get_binary_file_location("", "l10n-track");
|
||||
std::string contents = read_file(trackpath);
|
||||
std::vector<std::string> lines = utils::split(contents, '\n');
|
||||
foreach (const std::string &line, lines) {
|
||||
size_t p1 = line.find(fsep);
|
||||
if (p1 == std::string::npos)
|
||||
continue;
|
||||
std::string state = line.substr(0, p1);
|
||||
utils::strip(state);
|
||||
if (state == "ok") {
|
||||
size_t p2 = line.find(fsep, p1 + fsep.length());
|
||||
if (p2 == std::string::npos)
|
||||
continue;
|
||||
std::string relpath = line.substr(p1 + fsep.length(), p2 - p1 - fsep.length());
|
||||
uptodate_localized_files.insert(game_config::path + '/' + relpath);
|
||||
}
|
||||
}
|
||||
uptodate_localized_files.insert(""); // make sure not empty any more
|
||||
}
|
||||
return uptodate_localized_files.count(loc_file) == 1;
|
||||
}
|
||||
|
||||
// Return path to localized counterpart of the given file, if any, or empty string.
|
||||
// Localized counterpart may also be requested to have a suffix to base name.
|
||||
static std::string get_localized_path (const std::string& file, const std::string& suff = "")
|
||||
|
@ -346,7 +375,7 @@ static std::string get_localized_path (const std::string& file, const std::strin
|
|||
langs.push_back("en_US");
|
||||
foreach (const std::string &lang, langs) {
|
||||
std::string loc_file = dir + "l10n" + "/" + lang + "/" + loc_base;
|
||||
if (file_exists(loc_file)) {
|
||||
if (file_exists(loc_file) && localized_file_uptodate(loc_file)) {
|
||||
return loc_file;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue