Add localization support and docs

This commit is contained in:
2025-10-18 21:44:18 +02:00
parent 0fb168b050
commit 4166cf0460
15 changed files with 424 additions and 110 deletions

24
src/hooks/useLanguage.js Normal file
View File

@@ -0,0 +1,24 @@
import React from 'react';
import { translations, getInitialLanguage } from '../locales/index.js';
export const useLanguage = () => {
const [currentLanguage, setCurrentLanguage] = React.useState(getInitialLanguage);
// Get current translations
const t = translations[currentLanguage] || translations.en;
// Change language and save to localStorage
const changeLanguage = (lang) => {
if (translations[lang]) {
setCurrentLanguage(lang);
localStorage.setItem('medPlanAssistant_language', lang);
}
};
return {
currentLanguage,
changeLanguage,
t,
availableLanguages: Object.keys(translations)
};
};