Try to find an English locale ID which is available

wxLANGUAGE_ENGLISH corresponds to the "en" locale on Linux, which is
generally not installed, which resulted in English actually being the
system default locale.

Updates #1508.
This commit is contained in:
Thomas Goyne 2012-09-22 09:42:32 -07:00
parent c4f6e729f9
commit 9a6eb70f12
2 changed files with 35 additions and 2 deletions

View File

@ -52,9 +52,39 @@
AegisubLocale::~AegisubLocale() { AegisubLocale::~AegisubLocale() {
} }
int AegisubLocale::EnglishId() const {
static const int english_ids[] = {
wxLANGUAGE_ENGLISH,
wxLANGUAGE_ENGLISH_US,
wxLANGUAGE_ENGLISH_UK,
wxLANGUAGE_ENGLISH_AUSTRALIA,
wxLANGUAGE_ENGLISH_BELIZE,
wxLANGUAGE_ENGLISH_BOTSWANA,
wxLANGUAGE_ENGLISH_CANADA,
wxLANGUAGE_ENGLISH_CARIBBEAN,
wxLANGUAGE_ENGLISH_DENMARK,
wxLANGUAGE_ENGLISH_EIRE,
wxLANGUAGE_ENGLISH_JAMAICA,
wxLANGUAGE_ENGLISH_NEW_ZEALAND,
wxLANGUAGE_ENGLISH_PHILIPPINES,
wxLANGUAGE_ENGLISH_SOUTH_AFRICA,
wxLANGUAGE_ENGLISH_TRINIDAD,
wxLANGUAGE_ENGLISH_ZIMBABWE,
0
};
for (const int *id = english_ids; *id; ++id) {
if (wxLocale::IsAvailable(*id)) {
return *id;
}
}
return -1;
}
void AegisubLocale::Init(int language) { void AegisubLocale::Init(int language) {
if (language == -1) if (language == -1)
language = wxLANGUAGE_ENGLISH; language = EnglishId();
if (!wxLocale::IsAvailable(language)) if (!wxLocale::IsAvailable(language))
language = wxLANGUAGE_UNKNOWN; language = wxLANGUAGE_UNKNOWN;
@ -78,7 +108,9 @@ int AegisubLocale::PickLanguage() {
// Check if english is in it, else add it // Check if english is in it, else add it
if (langs.Index(wxLANGUAGE_ENGLISH) == wxNOT_FOUND) { if (langs.Index(wxLANGUAGE_ENGLISH) == wxNOT_FOUND) {
langs.Insert(wxLANGUAGE_ENGLISH, 0); int id = EnglishId();
if (id)
langs.Insert(id, 0);
} }
// Check if user local language is available, if so, make it first // Check if user local language is available, if so, make it first

View File

@ -46,6 +46,7 @@ class wxLocale;
class AegisubLocale { class AegisubLocale {
agi::scoped_ptr<wxLocale> locale; agi::scoped_ptr<wxLocale> locale;
wxArrayInt GetAvailableLanguages(); wxArrayInt GetAvailableLanguages();
int EnglishId() const;
public: public:
~AegisubLocale(); ~AegisubLocale();