Use localized language names from ICU rather than English names

This commit is contained in:
Thomas Goyne 2014-05-06 10:48:22 -07:00
parent 86ebd15ffb
commit 432640c045
4 changed files with 22 additions and 14 deletions

View File

@ -35,14 +35,13 @@
#include "aegisublocale.h"
#include "options.h"
#include "utils.h"
#include <libaegisub/path.h>
#include <algorithm>
#include <boost/locale.hpp>
#include <clocale>
#include <functional>
#include <wx/intl.h>
#include <wx/choicdlg.h> // Keep this last so wxUSE_CHOICEDLG is set.
@ -78,6 +77,7 @@ wxString AegisubLocale::PickLanguage() {
}
wxArrayString langs = GetTranslations()->GetAvailableTranslations(AEGISUB_CATALOG);
// No translations available, so don't bother asking the user
if (langs.empty() && !active_language)
return "en_US";
@ -94,13 +94,8 @@ wxString AegisubLocale::PickLanguage() {
// Generate names
wxArrayString langNames;
for (auto const& lang : langs) {
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);
if (info)
langNames.push_back(wxLocale::GetLanguageName(info->Language));
else
langNames.push_back(lang);
}
for (auto const& lang : langs)
langNames.push_back(LocalizedLanguageName(lang));
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCENTRE;
if (!active_language.empty())

View File

@ -444,10 +444,8 @@ wxMenu *SubsTextEditCtrl::GetLanguagesMenu(int base_id, wxString const& curLang,
auto languageMenu = new wxMenu;
languageMenu->AppendRadioItem(base_id, _("Disable"))->Check(curLang.empty());
for (size_t i = 0; i < langs.size(); ++i) {
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(langs[i]);
languageMenu->AppendRadioItem(base_id + i + 1, info ? info->Description : langs[i])->Check(langs[i] == curLang);
}
for (size_t i = 0; i < langs.size(); ++i)
languageMenu->AppendRadioItem(base_id + i + 1, LocalizedLanguageName(langs[i]))->Check(langs[i] == curLang);
return languageMenu;
}

View File

@ -49,7 +49,7 @@
#include <boost/filesystem.hpp>
#include <boost/format.hpp>
#include <map>
#include <unicode/locid.h>
#include <wx/clipbrd.h>
#include <wx/filedlg.h>
#include <wx/stdpaths.h>
@ -267,3 +267,16 @@ agi::fs::path OpenFileSelector(wxString const& message, std::string const& optio
agi::fs::path SaveFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent) {
return FileSelector(message, option_name, default_filename, default_extension, wildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT, parent);
}
wxString LocalizedLanguageName(wxString const& lang) {
Locale iculoc(lang.c_str());
if (!iculoc.isBogus()) {
UnicodeString ustr;
iculoc.getDisplayName(iculoc, ustr);
return wxString(ustr.getBuffer());
}
if (auto info = wxLocale::FindLanguageInfo(lang))
return info->Description;
return lang;
}

View File

@ -112,3 +112,5 @@ wxString FontFace(std::string opt_prefix);
agi::fs::path OpenFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent);
agi::fs::path SaveFileSelector(wxString const& message, std::string const& option_name, std::string const& default_filename, std::string const& default_extension, wxString const& wildcard, wxWindow *parent);
wxString LocalizedLanguageName(wxString const& lang);