Skip to content

Commit

Permalink
Fix Chinese addon translations
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jun 22, 2024
1 parent c596b4b commit 5b755c6
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/addons/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,20 @@ const getEditorMode = () => {
return 'editor';
};

const language = reduxInstance.state.locales.locale.split('-')[0];
/**
* @returns {string} Locale code
*/
const getLocale = () => {
const locale = reduxInstance.state.locales.locale;
if (Object.prototype.hasOwnProperty.call(l10nEntries, locale)) {
return locale;
}
return locale.split('-')[0];
};
const language = getLocale();

const getTranslations = async () => {
if (l10nEntries[language]) {
if (Object.prototype.hasOwnProperty.call(l10nEntries, language)) {
const localeMessages = await l10nEntries[language]();
Object.assign(addonMessages, localeMessages);
}
Expand Down

0 comments on commit 5b755c6

Please sign in to comment.