Added a new experimental feature in the new widget library.
This feature disables languages not available on the system. It has only been tested on Linux and it can use more testing on other platforms. (bug #11212)
This commit is contained in:
parent
97f98b5390
commit
0f6f0a1525
5 changed files with 73 additions and 0 deletions
|
@ -10,3 +10,8 @@ is making sure that spelling/grammer/whatever is usable and that you are using
|
|||
|
||||
The release team should empty this file after each release.
|
||||
|
||||
|
||||
There is a new experimental function to gray out not available languages in the
|
||||
language selection dialog. This feature is available when Wesnoth is started
|
||||
with the --new-widgets parameter. Packagers of various platforms are encouraged
|
||||
to test this feature and report bugs when found.
|
||||
|
|
|
@ -17,10 +17,14 @@ Version 1.5.0+svn:
|
|||
* graphics:
|
||||
* new ford graphics from Syntax_Error
|
||||
* added a sea serpent portrait by Pic
|
||||
* various improvements to the new widget library
|
||||
* language and i18n:
|
||||
* new translations: Friulian, Macedonian
|
||||
* updated translations: Chinese, Czech, Danish, Finnish, French, German, Italian,
|
||||
Polish, Russian, Slovak, Spanish, Turkish
|
||||
* the new widget library supports disabling of rows in a listbox, this is
|
||||
used to deactivate not available languages. This feature is experimental
|
||||
and only available when started with --new-widgets (bug #11212)
|
||||
* multiplayer:
|
||||
* revised maps: Den of Onis
|
||||
* Python AI:
|
||||
|
|
|
@ -51,6 +51,8 @@ void tlanguage_selection::show(CVideo& video)
|
|||
std::cerr << "select row " << list->get_item_count() - 1 << ".\n";
|
||||
list->select_row(list->get_item_count() - 1);
|
||||
}
|
||||
|
||||
list->set_row_active(list->get_item_count() - 1, lang.available());
|
||||
}
|
||||
|
||||
window.recalculate_size();
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "config.hpp"
|
||||
#include "filesystem.hpp"
|
||||
#include "foreach.hpp"
|
||||
#include "game_config.hpp"
|
||||
#include "gettext.hpp"
|
||||
#include "language.hpp"
|
||||
|
@ -35,6 +36,41 @@
|
|||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <stdexcept>
|
||||
|
||||
/** Tests one locale to be available. */
|
||||
static bool has_locale(const char* s) {
|
||||
try {
|
||||
// The way to find out whether a locale is available is to set it and
|
||||
// hope not runtime error gets thrown.
|
||||
std::locale dummy(s);
|
||||
std::cerr << "Locale : " << s << " found.\n";
|
||||
return true;
|
||||
} catch (std::runtime_error&) {
|
||||
std::cerr << "Locale : " << s << " not found.\n";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/** Test the locale for a language and it's utf-8 variations. */
|
||||
static bool has_language(const std::string& language)
|
||||
{
|
||||
if(has_locale(language.c_str())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string utf = language + ".utf-8";
|
||||
if(has_locale(utf.c_str())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
utf = language + ".UTF-8";
|
||||
if(has_locale(utf.c_str())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
namespace {
|
||||
language_def current_language;
|
||||
|
@ -58,6 +94,25 @@ bool language_def::operator== (const language_def& a) const
|
|||
return ((language == a.language) /* && (localename == a.localename) */ );
|
||||
}
|
||||
|
||||
bool language_def::available() const
|
||||
{
|
||||
#ifdef USE_DUMMYLOCALES
|
||||
// Dummy has every language available.
|
||||
return true;
|
||||
#else
|
||||
if(has_language(localename)) {
|
||||
return true;
|
||||
} else {
|
||||
foreach(const std::string& lang, alternates) {
|
||||
if(has_language(lang)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
symbol_table string_table;
|
||||
|
||||
const t_string& symbol_table::operator[](const std::string& key) const
|
||||
|
|
|
@ -50,6 +50,13 @@ struct language_def
|
|||
t_string language;
|
||||
bool rtl; // A right to left language? (e.g: Hebrew)
|
||||
bool operator== (const language_def&) const;
|
||||
|
||||
/**
|
||||
* Is the locale available on the system?
|
||||
*
|
||||
* If the dummy locales are selected we always return true.
|
||||
*/
|
||||
bool available() const;
|
||||
};
|
||||
|
||||
std::string languagedef_name (const language_def& def);
|
||||
|
|
Loading…
Add table
Reference in a new issue