Skip to content

Commit

Permalink
Merge pull request #938 from sorin-davidoi/lang-respect-fallbacks
Browse files Browse the repository at this point in the history
fix(lang): respect fallback languages
  • Loading branch information
cheeaun authored Nov 19, 2024
2 parents 06b56a8 + 46b5faa commit 2e83df6
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/lang.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { i18n } from '@lingui/core';
import {
detect,
fromNavigator,
fromStorage,
fromUrl,
multipleDetect,
} from '@lingui/detect-locale';
import Locale from 'intl-locale-textinfo-polyfill';

Expand Down Expand Up @@ -54,15 +54,16 @@ export async function activateLang(lang) {
}

export function initActivateLang() {
const lang = detect(
const languages = multipleDetect(
fromUrl('lang'),
fromStorage('lang'),
fromNavigator(),
PHANPY_DEFAULT_LANG,
DEFAULT_LANG,
);
const matchedLang =
ALL_LOCALES.find((l) => l === lang) || localeMatch(lang, ALL_LOCALES);
languages.find((l) => ALL_LOCALES.includes(l)) ||
localeMatch(languages, ALL_LOCALES);
activateLang(matchedLang);

// const yes = confirm(t`Reload to apply language setting?`);
Expand Down

0 comments on commit 2e83df6

Please sign in to comment.