Skip to content
Merged
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
4 changes: 2 additions & 2 deletions apps/frontend/src/lib/i18n/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export const languageNames: Record<SupportedLanguage, string> = {
/**
* Initialize i18next with the given language or auto-detect
*/
export function initI18n(initialLanguage?: SupportedLanguage) {
i18next.use(LanguageDetector).init({
export async function initI18n(initialLanguage?: SupportedLanguage) {
await i18next.use(LanguageDetector).init({
resources: {
en: { translation: en },
de: { translation: de },
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/lib/stores/locale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function createLocaleStore() {
*/
initialize: async (userLanguage?: SupportedLanguage) => {
// Initialize i18next with user's preference or auto-detect
initI18n(userLanguage);
await initI18n(userLanguage);
const detectedLang = getCurrentLanguage();

// Update document lang attribute
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
userPreferences,
} from '$lib/stores/auth';
import { circles } from '$lib/stores/circles';
import { locale } from '$lib/stores/locale';
import { isLocaleInitialized, locale } from '$lib/stores/locale';

interface Props {
children: Snippet;
Expand Down Expand Up @@ -52,7 +52,7 @@ $effect(() => {
// Sync language when user preferences change (e.g., after login)
$effect(() => {
const prefs = $userPreferences;
if (prefs?.language && prefs.language !== locale.getLanguage()) {
if ($isLocaleInitialized && prefs?.language && prefs.language !== locale.getLanguage()) {
locale.setLanguage(prefs.language as SupportedLanguage);
}
});
Expand Down
Loading