Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions app/javascript/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,13 @@ export default function App() {
// i18n
const { i18n } = useTranslation();
useEffect(() => {
i18n.changeLanguage(currentUser?.language);
}, [currentUser?.language]);
if (currentUser?.language) {
i18n.changeLanguage(currentUser.language).catch(() => {
// Silently fall back to default language if change fails
console.warn(`Failed to load language: ${currentUser.language}`);
});
}
}, [currentUser?.language, i18n]);

// Greenlight V3 brand-color theming
const { isLoading, data: brandColors } = useSiteSetting(['PrimaryColor', 'PrimaryColorLight']);
Expand Down
11 changes: 2 additions & 9 deletions app/javascript/i18n.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,7 @@ i18next
backend: {
loadPath: `${process.env.RELATIVE_URL_ROOT}/api/v1/locales/{{lng}}.json`,
},
load: 'currentOnly',
fallbackLng: (locale) => {
const fallbacks = [];
if (locale?.indexOf('-') > -1) {
fallbacks.push(locale.split('-')[0]);
}
fallbacks.push('en');
return fallbacks;
},
load: 'languageOnly',
fallbackLng: ['en'],
});
export default i18next;