mirror of
https://github.com/aseprite/aseprite.git
synced 2025-04-10 03:44:16 +00:00
Select "English" if the current language is not found in Preferences
If the user preferences file (aseprite.ini) contained a non-existent language, the first option of the languages combo box was selected, which might lead to a confusing situation where just opening the preferences dialog will change from English to other language (non-English, the first language in the combobox).
This commit is contained in:
parent
4d5bf53be8
commit
6a12c7014d
@ -1317,9 +1317,20 @@ private:
|
|||||||
if (language()->getItemCount() > 0)
|
if (language()->getItemCount() > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Select current language by lang ID
|
// Check if the current language exists, in other case select English.
|
||||||
Strings* strings = Strings::instance();
|
Strings* strings = Strings::instance();
|
||||||
std::string curLang = strings->currentLanguage();
|
std::string curLang = strings->currentLanguage();
|
||||||
|
bool found = false;
|
||||||
|
for (const LangInfo& lang : strings->availableLanguages()) {
|
||||||
|
if (lang.id == curLang) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
curLang = Strings::kDefLanguage;
|
||||||
|
|
||||||
|
// Select current language by lang ID
|
||||||
for (const LangInfo& lang : strings->availableLanguages()) {
|
for (const LangInfo& lang : strings->availableLanguages()) {
|
||||||
int i = language()->addItem(new LangItem(lang));
|
int i = language()->addItem(new LangItem(lang));
|
||||||
if (lang.id == curLang)
|
if (lang.id == curLang)
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
namespace app {
|
namespace app {
|
||||||
|
|
||||||
static Strings* singleton = nullptr;
|
static Strings* singleton = nullptr;
|
||||||
static const char* kDefLanguage = "en";
|
|
||||||
|
const char* Strings::kDefLanguage = "en";
|
||||||
|
|
||||||
// static
|
// static
|
||||||
void Strings::createInstance(Preferences& pref,
|
void Strings::createInstance(Preferences& pref,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// Aseprite
|
// Aseprite
|
||||||
// Copyright (C) 2023 Igara Studio S.A.
|
// Copyright (C) 2023-2024 Igara Studio S.A.
|
||||||
// Copyright (C) 2016-2018 David Capello
|
// Copyright (C) 2016-2018 David Capello
|
||||||
//
|
//
|
||||||
// This program is distributed under the terms of
|
// This program is distributed under the terms of
|
||||||
@ -25,6 +25,8 @@ namespace app {
|
|||||||
// Singleton class to load and access "strings/en.ini" file.
|
// Singleton class to load and access "strings/en.ini" file.
|
||||||
class Strings : public app::gen::Strings<app::Strings> {
|
class Strings : public app::gen::Strings<app::Strings> {
|
||||||
public:
|
public:
|
||||||
|
static const char* kDefLanguage;
|
||||||
|
|
||||||
static void createInstance(Preferences& pref,
|
static void createInstance(Preferences& pref,
|
||||||
Extensions& exts);
|
Extensions& exts);
|
||||||
static Strings* instance();
|
static Strings* instance();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user