mirror of
https://github.com/clangen/musikcube.git
synced 2025-03-29 01:20:14 +00:00
Fixed a crash when falling back to default dimen values.
This commit is contained in:
parent
c59ec77358
commit
a87c8563c0
@ -168,17 +168,16 @@ std::string Locale::Translate(const char* key) {
|
||||
|
||||
int Locale::Dimension(const char* key, int defaultValue) {
|
||||
if (!this->localeData.is_null()) { /* current locale */
|
||||
const nlohmann::json& strings = this->localeData.value(KEY_DIMENSIONS, empty);
|
||||
auto it = strings.find(key);
|
||||
if (it != strings.end()) {
|
||||
const nlohmann::json& dimens = this->localeData.value(KEY_DIMENSIONS, empty);
|
||||
auto it = dimens.find(key);
|
||||
if (it != dimens.end()) {
|
||||
return it.value();
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->defaultLocaleData.is_null()) { /* fall back to default */
|
||||
const nlohmann::json& strings = this->defaultLocaleData.value(KEY_DIMENSIONS, empty);
|
||||
auto it = strings.find(key);
|
||||
return (it != strings.end()) ? it.value() : key;
|
||||
const nlohmann::json& dimens = this->defaultLocaleData.value(KEY_DIMENSIONS, empty);
|
||||
return dimens.value(key, defaultValue);
|
||||
}
|
||||
|
||||
return defaultValue; /* not found anywhere */
|
||||
|
Loading…
x
Reference in New Issue
Block a user