fix crash when using "exotic" locales which undefined languageNames

see also #9737
This commit is contained in:
Martin Raifer
2023-07-07 13:29:09 +02:00
parent 457a2101c6
commit db886f5dd7
2 changed files with 5 additions and 3 deletions
+2
View File
@@ -55,6 +55,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
* Fix dysfunctional autocomplete of wikidata fields for some languages with country-codes ([#9638])
* Prevent certain tag values from corrupting css classes when they contain whitespaces ([#9637], thanks [@k-yle])
* Don't move the cursor to the end of (some) input fields while editing in the middle ([#9233])
* Fix crash when using certain locales (e.g. `fr-FR`) ([#9737], thanks [@k-yle])
#### :earth_asia: Localization
* Send `Accept-Language` header on Nominatim API calls ([#9501], thanks [@k-yle])
* Add Address and Phone format for India ([#9482], thanks [@biswajit-k])
@@ -89,6 +90,7 @@ _Breaking developer changes, which may affect downstream projects or sites that
[#9638]: https://github.com/openstreetmap/iD/pull/9638
[#9640]: https://github.com/openstreetmap/iD/issues/9640
[#9650]: https://github.com/openstreetmap/iD/pull/9650
[#9737]: https://github.com/openstreetmap/iD/pull/9737
[@biswajit-k]: https://github.com/biswajit-k
[@bryceco]: https://github.com/bryceco
+3 -3
View File
@@ -401,7 +401,7 @@ export function coreLocalizer() {
localizer.languageName = (code, options) => {
if (_languageNames[code]) { // name in locale language
if (_languageNames && _languageNames[code]) { // name in locale language
// e.g. "German"
return _languageNames[code];
}
@@ -418,9 +418,9 @@ export function coreLocalizer() {
} else if (langInfo.base && langInfo.script) {
const base = langInfo.base; // the code of the language this is based on
if (_languageNames[base]) { // base language name in locale language
if (_languageNames && _languageNames[base]) { // base language name in locale language
const scriptCode = langInfo.script;
const script = _scriptNames[scriptCode] || scriptCode;
const script = (_scriptNames && _scriptNames[scriptCode]) || scriptCode;
// e.g. "Serbian (Cyrillic)"
return localizer.t('translate.language_and_code', { language: _languageNames[base], code: script });