Don't use StandardPaths before OnInit is called
AegisubLocale is created extremely early in the application initialization, and using StandardPaths in its constructor resulted in ?user being set to an incorrect value as the app name hadn't been set yet.
This commit is contained in:
parent
662cf01493
commit
7343392823
2 changed files with 12 additions and 6 deletions
|
@ -56,13 +56,17 @@
|
|||
#define AEGISUB_CATALOG "aegisub"
|
||||
#endif
|
||||
|
||||
AegisubLocale::AegisubLocale() {
|
||||
wxTranslations::Set(new wxTranslations);
|
||||
wxTranslations *AegisubLocale::GetTranslations() {
|
||||
wxTranslations *translations = wxTranslations::Get();
|
||||
if (!translations) {
|
||||
wxTranslations::Set(translations = new wxTranslations);
|
||||
wxFileTranslationsLoader::AddCatalogLookupPathPrefix(StandardPaths::DecodePath("?data/locale/"));
|
||||
}
|
||||
return translations;
|
||||
}
|
||||
|
||||
void AegisubLocale::Init(wxString const& language) {
|
||||
wxTranslations *translations = wxTranslations::Get();
|
||||
wxTranslations *translations = GetTranslations();
|
||||
translations->SetLanguage(language);
|
||||
translations->AddCatalog(AEGISUB_CATALOG);
|
||||
translations->AddStdCatalog();
|
||||
|
@ -73,7 +77,7 @@ void AegisubLocale::Init(wxString const& language) {
|
|||
}
|
||||
|
||||
wxString AegisubLocale::PickLanguage() {
|
||||
wxArrayString langs = wxTranslations::Get()->GetAvailableTranslations(AEGISUB_CATALOG);
|
||||
wxArrayString langs = GetTranslations()->GetAvailableTranslations(AEGISUB_CATALOG);
|
||||
langs.insert(langs.begin(), "en_US");
|
||||
|
||||
// Check if user local language is available, if so, make it first
|
||||
|
|
|
@ -34,6 +34,8 @@
|
|||
/// @ingroup utility
|
||||
///
|
||||
|
||||
class wxTranslations;
|
||||
|
||||
/// DOCME
|
||||
/// @class AegisubLocale
|
||||
/// @brief DOCME
|
||||
|
@ -41,8 +43,8 @@
|
|||
/// DOCME
|
||||
class AegisubLocale {
|
||||
wxString active_language;
|
||||
wxTranslations *GetTranslations();
|
||||
public:
|
||||
AegisubLocale();
|
||||
void Init(wxString const& language);
|
||||
wxString PickLanguage();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue