Skip to content

Commit

Permalink
Fix handling of current locale
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Sep 28, 2021
1 parent e865834 commit 5dd5653
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/translation/src/translation.ts
Expand Up @@ -19,6 +19,15 @@ export class Translation {
try {
const response = await fetch(apiURL);
const json = JSON.parse(await response.text());
if (this._prevLocale !== 'all' && locale === 'all') {
// TODO: fix this logic upstream?
const prev = this._prevLocale;
json.data[prev].displayName = json.data[prev].nativeName;
if (prev !== 'en') {
json.data['en'].displayName = `${json.data['en'].nativeName} (default)`;
}
}
this._prevLocale = locale;
return json;
} catch (e) {
if (locale) {
Expand All @@ -35,4 +44,6 @@ export class Translation {
};
}
}

private _prevLocale = '';
}

0 comments on commit 5dd5653

Please sign in to comment.