Languages in the language selection are now sorted on name instead of code.

Based on a patch by stikonas who also spotted the not sorted problem.
This commit is contained in:
Mark de Wever 2008-07-05 09:19:55 +00:00
parent 4a4a3d99f5
commit 45d8c07fc2
15 changed files with 32 additions and 12 deletions

View file

@ -10,6 +10,8 @@ Version 1.5.1+svn:
* new translation: Latvian
* updated translations: Arabic, Finnish, French, German, Greek, Lithuanian,
Serbian
* languages in the language selection are now sorted on name instead of
code.
* WML engine:
* When examining stored units, now the attacks, max_hitpoints, max_moves,
and max_experience are the "real" values and can also be modified.

View file

@ -1,5 +1,6 @@
[locale]
name="العربية (Arabic)"
sort_name = "Arabic"
locale=ar_AR
alternates=ar_AE, ar_BH, ar_DZ, ar_EG, ar_IN, ar_IQ, ar_JO, ar_KW, ar_LB, ar_LY, ar_MA, ar_OM, ar_QA, ar_SA, ar_SD, ar_SY, ar_TN, ar_YE
dir=rtl

View file

@ -1,4 +1,5 @@
[locale]
name="Български (Bulgarski)"
sort_name = "Bulgarski"
locale=bg_BG
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="Ελληνικά (Ellinika)"
sort_name = "Ellinika"
locale=el_GR
[/locale]

View file

@ -1,5 +1,6 @@
[locale]
name="עברית (Hebrew)"
sort_name = "Hebrew"
locale=he_IL
dir=rtl
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="日本語 (Nihongo)"
sort_name = "Nihongo"
locale=ja_JP
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="한국어 (Korean)"
locale=ko_KR
name="한국어 (Korean)"
sort_name = "Korean"
locale=ko_KR
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="Македонски (Makedonski)"
sort_name = "Makedonski"
locale=mk_MK
[/locale]

View file

@ -1,4 +1,4 @@
[locale]
name="Norsk bokmål"
locale=nb_NO
name="Norsk bokmål"
locale=nb_NO
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="Русский (Russkij)"
sort_name = "Russkij"
locale=ru_RU
[/locale]

View file

@ -1,4 +1,4 @@
[locale]
name="Filipino"
locale=tl_PH
name="Filipino"
locale=tl_PH
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="中文 (Zhongwen)"
sort_name = "Zhongwen"
locale=zh_CN
[/locale]

View file

@ -1,4 +1,5 @@
[locale]
name="繁體中文(Chinese traditional)"
sort_name = "Chinese traditional"
locale=zh_TW
[/locale]

View file

@ -153,13 +153,13 @@ bool load_language_list()
known_languages.clear();
known_languages.push_back(
language_def("", t_string(N_("System default language"), "wesnoth"), "ltr"));
language_def("", t_string(N_("System default language"), "wesnoth"), "ltr", "", "A"));
config::const_child_itors langs = cfg.child_range("locale");
for(;langs.first != langs.second; ++langs.first) {
known_languages.push_back(
language_def((**langs.first)["locale"], (**langs.first)["name"], (**langs.first)["dir"],
(**langs.first)["alternates"]));
(**langs.first)["alternates"], (**langs.first)["sort_name"]));
}
return true;
@ -167,6 +167,9 @@ bool load_language_list()
std::vector<language_def> get_languages()
{
// We sort every time, the local might have changed which can modify the
// sort order.
std::sort(known_languages.begin(), known_languages.end());
return known_languages;
}

View file

@ -33,23 +33,28 @@ struct language_def
localename(),
alternates(),
language(),
sort_name(),
rtl(false)
{}
language_def(const std::string& name, const t_string& lang, const std::string& dir,
const std::string &salternates = "") :
const std::string &salternates = "", const std::string& sort_name = "") :
localename(name),
alternates(),
alternates(utils::split(salternates)),
language(lang),
sort_name(sort_name.empty() ? std::string(lang) : sort_name),
rtl(dir == "rtl")
{
alternates = utils::split(salternates);
}
}
std::string localename;
std::vector<std::string> alternates;
t_string language;
std::string sort_name;
bool rtl; // A right to left language? (e.g: Hebrew)
bool operator== (const language_def&) const;
bool operator< (const language_def& a) const
{ return sort_name < a.sort_name; }
/**
* Is the locale available on the system?