Skip to content

Commit 5b755c6

Browse files
committed
Fix Chinese addon translations
1 parent c596b4b commit 5b755c6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/addons/api.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,20 @@ const getEditorMode = () => {
115115
return 'editor';
116116
};
117117

118-
const language = reduxInstance.state.locales.locale.split('-')[0];
118+
/**
119+
* @returns {string} Locale code
120+
*/
121+
const getLocale = () => {
122+
const locale = reduxInstance.state.locales.locale;
123+
if (Object.prototype.hasOwnProperty.call(l10nEntries, locale)) {
124+
return locale;
125+
}
126+
return locale.split('-')[0];
127+
};
128+
const language = getLocale();
129+
119130
const getTranslations = async () => {
120-
if (l10nEntries[language]) {
131+
if (Object.prototype.hasOwnProperty.call(l10nEntries, language)) {
121132
const localeMessages = await l10nEntries[language]();
122133
Object.assign(addonMessages, localeMessages);
123134
}

0 commit comments

Comments
 (0)