Skip to content

Commit

Permalink
fix: correct language logic
Browse files Browse the repository at this point in the history
  • Loading branch information
nshenderov committed Oct 4, 2024
1 parent b5f0991 commit 9e43157
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions admin/src/Input/config/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,26 @@ const detecti18n = () => {

export const setLanguage = async (config) => {
const i18nLang = detecti18n();

const preferedLanguage = auth.getUserInfo().preferedLanguage || 'en';

const {
ui = preferedLanguage,
content,
ui = config.language && typeof config.language === 'string' ?
config.language
: preferedLanguage,
textPartLanguage,
ignorei18n,
} = config.language || {};

if (i18nLang) {
if (i18nLang && !ignorei18n) {
config.language = {
ui: typeof config.language === 'string' ? config.language : ui,
content: ignorei18n ? content : i18nLang,
ui: ui,
content: i18nLang,
textPartLanguage: textPartLanguage,
};
}

if (!config.language) {
config.language = preferedLanguage;
if (ui !== 'en') {
await importLang(config, ui);
}

await importLang(
config,
typeof config.language === 'string' ? config.language : ui
);
};

0 comments on commit 9e43157

Please sign in to comment.