Skip to content

Commit

Permalink
frontend: ensure falling back to native langauge
Browse files Browse the repository at this point in the history
  • Loading branch information
thisconnect committed Nov 15, 2024
1 parent 91d7407 commit 998b4de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion frontends/web/src/components/guide/entry.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const Entry = (props: TProps) => {
<div className={[style.entryContent, shown ? style.expanded : ''].join(' ')}>
{shown ? (
<div className="flex-1">
{entry.text.trim().split('\n').map((p, idx) => <p key={idx}>{p}</p>)}
{entry?.text?.trim().split('\n').map((p, idx) => <p key={idx}>{p}</p>)}
{entry.link && (
<p>
<A
Expand Down
11 changes: 8 additions & 3 deletions frontends/web/src/i18n/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ i18Init.init({
}
});

// load the default language first
loadLanguage(defaultLang);

i18n.on('languageChanged', async (lng) => {
// changei18nLanguage triggers languageChanged, thus this check to prevent loop
if (isChangingLanguage) {
Expand Down Expand Up @@ -127,4 +124,12 @@ i18n.on('languageChanged', async (lng) => {
}
});

i18n.on('initialized', () => {
languageFromConfig.detect((lang) => {
if (lang && typeof lang === 'string') {
changei18nLanguage(localeMainLanguage(lang));
}
});
});

export { i18n };

0 comments on commit 998b4de

Please sign in to comment.