Skip to content

Commit

Permalink
Only initialize language after auto-detection
Browse files Browse the repository at this point in the history
  • Loading branch information
SupSuper committed Jun 11, 2021
1 parent f3eea81 commit 8d45159
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
6 changes: 3 additions & 3 deletions src/Engine/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,6 @@ void Game::loadLanguages()
const std::string defaultLang = "en-US";
std::string currentLang = defaultLang;

delete _lang;
_lang = new Language();

std::ostringstream ss;
ss << "common/Language/" << defaultLang << ".yml";
std::string defaultPath = CrossPlatform::searchDataFile(ss.str());
Expand Down Expand Up @@ -606,6 +603,9 @@ void Game::loadLanguages()
}
Options::language = currentLang;

delete _lang;
_lang = new Language();

// Load default and current language
std::ostringstream ssDefault, ssCurrent;
ssDefault << "/Language/" << defaultLang << ".yml";
Expand Down
37 changes: 17 additions & 20 deletions src/Engine/Language.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,33 +99,30 @@ Language::Language() : _handler(0), _direction(DIRECTION_LTR), _wrap(WRAP_WORDS)
}

std::string id = Options::language;
if (!id.empty())
_handler = LanguagePlurality::create(id);
if (std::find(_rtl.begin(), _rtl.end(), id) == _rtl.end())
{
_handler = LanguagePlurality::create(id);
if (std::find(_rtl.begin(), _rtl.end(), id) == _rtl.end())
{
_direction = DIRECTION_LTR;
}
else
{
_direction = DIRECTION_RTL;
}
if (Options::wordwrap == WRAP_AUTO)
_direction = DIRECTION_LTR;
}
else
{
_direction = DIRECTION_RTL;
}
if (Options::wordwrap == WRAP_AUTO)
{
if (std::find(_cjk.begin(), _cjk.end(), id) == _cjk.end())
{
if (std::find(_cjk.begin(), _cjk.end(), id) == _cjk.end())
{
_wrap = WRAP_WORDS;
}
else
{
_wrap = WRAP_LETTERS;
}
_wrap = WRAP_WORDS;
}
else
{
_wrap = Options::wordwrap;
_wrap = WRAP_LETTERS;
}
}
else
{
_wrap = Options::wordwrap;
}
}

/**
Expand Down

0 comments on commit 8d45159

Please sign in to comment.