Skip to content

Commit

Permalink
Select "English" if the current language is not found in Preferences
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
dacap committed Apr 8, 2024
1 parent 4d5bf53 commit 6a12c70
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
13 changes: 12 additions & 1 deletion src/app/commands/cmd_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1317,9 +1317,20 @@ class OptionsWindow : public app::gen::Options {
if (language()->getItemCount() > 0)
return;

// Select current language by lang ID
// Check if the current language exists, in other case select English.
Strings* strings = Strings::instance();
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()) {
int i = language()->addItem(new LangItem(lang));
if (lang.id == curLang)
Expand Down
3 changes: 2 additions & 1 deletion src/app/i18n/strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
namespace app {

static Strings* singleton = nullptr;
static const char* kDefLanguage = "en";

const char* Strings::kDefLanguage = "en";

// static
void Strings::createInstance(Preferences& pref,
Expand Down
4 changes: 3 additions & 1 deletion src/app/i18n/strings.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Aseprite
// Copyright (C) 2023 Igara Studio S.A.
// Copyright (C) 2023-2024 Igara Studio S.A.
// Copyright (C) 2016-2018 David Capello
//
// This program is distributed under the terms of
Expand All @@ -25,6 +25,8 @@ namespace app {
// Singleton class to load and access "strings/en.ini" file.
class Strings : public app::gen::Strings<app::Strings> {
public:
static const char* kDefLanguage;

static void createInstance(Preferences& pref,
Extensions& exts);
static Strings* instance();
Expand Down

0 comments on commit 6a12c70

Please sign in to comment.