Imporve the i18 and frontend UI pages

This commit is contained in:
Urtzi Alfaro
2025-09-22 16:10:08 +02:00
parent ee36c45d25
commit 8d54202e91
32 changed files with 875 additions and 434 deletions

View File

@@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { useCallback, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useUIStore } from '../stores/ui.store';
import { type SupportedLanguage } from '../locales';
@@ -10,18 +10,20 @@ import { type SupportedLanguage } from '../locales';
export function useLanguageSwitcher() {
const { i18n } = useTranslation();
const { language: uiLanguage, setLanguage: setUILanguage } = useUIStore();
const [isChanging, setIsChanging] = useState(false);
const changeLanguage = useCallback(async (newLanguage: SupportedLanguage) => {
try {
setIsChanging(true);
// Only change i18n language - let the i18n event handler update UI store
await i18n.changeLanguage(newLanguage);
setIsChanging(false);
} catch (error) {
console.error('Failed to change language:', error);
setIsChanging(false);
}
}, [i18n]);
const isChanging = i18n.isLanguageChangingTo !== false;
return {
currentLanguage: i18n.language as SupportedLanguage,
changeLanguage,