mirror of https://github.com/odrling/Aegisub
Use localized language names from ICU rather than English names
This commit is contained in:
parent
86ebd15ffb
commit
432640c045
|
@ -35,14 +35,13 @@
|
||||||
#include "aegisublocale.h"
|
#include "aegisublocale.h"
|
||||||
|
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
#include <libaegisub/path.h>
|
#include <libaegisub/path.h>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <boost/locale.hpp>
|
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include <wx/intl.h>
|
#include <wx/intl.h>
|
||||||
#include <wx/choicdlg.h> // Keep this last so wxUSE_CHOICEDLG is set.
|
#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);
|
wxArrayString langs = GetTranslations()->GetAvailableTranslations(AEGISUB_CATALOG);
|
||||||
|
|
||||||
// No translations available, so don't bother asking the user
|
// No translations available, so don't bother asking the user
|
||||||
if (langs.empty() && !active_language)
|
if (langs.empty() && !active_language)
|
||||||
return "en_US";
|
return "en_US";
|
||||||
|
@ -94,13 +94,8 @@ wxString AegisubLocale::PickLanguage() {
|
||||||
|
|
||||||
// Generate names
|
// Generate names
|
||||||
wxArrayString langNames;
|
wxArrayString langNames;
|
||||||
for (auto const& lang : langs) {
|
for (auto const& lang : langs)
|
||||||
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(lang);
|
langNames.push_back(LocalizedLanguageName(lang));
|
||||||
if (info)
|
|
||||||
langNames.push_back(wxLocale::GetLanguageName(info->Language));
|
|
||||||
else
|
|
||||||
langNames.push_back(lang);
|
|
||||||
}
|
|
||||||
|
|
||||||
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCENTRE;
|
long style = wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxOK | wxCENTRE;
|
||||||
if (!active_language.empty())
|
if (!active_language.empty())
|
||||||
|
|
|
@ -444,10 +444,8 @@ wxMenu *SubsTextEditCtrl::GetLanguagesMenu(int base_id, wxString const& curLang,
|
||||||
auto languageMenu = new wxMenu;
|
auto languageMenu = new wxMenu;
|
||||||
languageMenu->AppendRadioItem(base_id, _("Disable"))->Check(curLang.empty());
|
languageMenu->AppendRadioItem(base_id, _("Disable"))->Check(curLang.empty());
|
||||||
|
|
||||||
for (size_t i = 0; i < langs.size(); ++i) {
|
for (size_t i = 0; i < langs.size(); ++i)
|
||||||
const wxLanguageInfo *info = wxLocale::FindLanguageInfo(langs[i]);
|
languageMenu->AppendRadioItem(base_id + i + 1, LocalizedLanguageName(langs[i]))->Check(langs[i] == curLang);
|
||||||
languageMenu->AppendRadioItem(base_id + i + 1, info ? info->Description : langs[i])->Check(langs[i] == curLang);
|
|
||||||
}
|
|
||||||
|
|
||||||
return languageMenu;
|
return languageMenu;
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/format.hpp>
|
#include <boost/format.hpp>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <unicode/locid.h>
|
||||||
#include <wx/clipbrd.h>
|
#include <wx/clipbrd.h>
|
||||||
#include <wx/filedlg.h>
|
#include <wx/filedlg.h>
|
||||||
#include <wx/stdpaths.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) {
|
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);
|
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;
|
||||||
|
}
|
||||||
|
|
|
@ -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 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);
|
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);
|
||||||
|
|
Loading…
Reference in New Issue