FIX: [STUDIO-3005] support sub language (region) in locale

Change-Id: If7af7fc79d84f68dcc495f8f8eefa928e93994a1
This commit is contained in:
chunmao.guo 2023-05-30 08:51:45 +08:00 committed by Lane.Wei
parent 767edb03e0
commit 7cba0882b8
2 changed files with 49 additions and 51 deletions

View file

@ -104,7 +104,8 @@ wxBoxSizer *PreferencesDialog::create_item_language_combobox(
auto combobox = new ::ComboBox(parent, wxID_ANY, wxEmptyString, wxDefaultPosition, DESIGN_LARGE_COMBOBOX_SIZE, 0, nullptr, wxCB_READONLY);
combobox->SetFont(::Label::Body_13);
combobox->GetDropDown().SetFont(::Label::Body_13);
auto language = app_config->get(param);
m_current_language_selected = -1;
std::vector<wxString>::iterator iter;
for (size_t i = 0; i < vlist.size(); ++i) {
auto language_name = vlist[i]->Description;
@ -137,11 +138,20 @@ wxBoxSizer *PreferencesDialog::create_item_language_combobox(
language_name = wxString::FromUTF8("\x69\x74\x61\x6c\x69\x61\x6e\x6f");
}
if (app_config->get(param) == vlist[i]->CanonicalName) {
if (language == vlist[i]->CanonicalName) {
m_current_language_selected = i;
}
combobox->Append(language_name);
}
if (m_current_language_selected == -1 && language.size() >= 5) {
language = language.substr(0, 2);
for (size_t i = 0; i < vlist.size(); ++i) {
if (vlist[i]->CanonicalName.StartsWith(language)) {
m_current_language_selected = i;
break;
}
}
}
combobox->SetSelection(m_current_language_selected);
m_sizer_combox->Add(combobox, 0, wxALIGN_CENTER, 0);