import { Language, TranslationKeys } from './types';

// Dynamic language loader
export const loadLanguage = async (language: Language): Promise<TranslationKeys> => {
    try {
        let translations: TranslationKeys;
        
        switch (language) {
            case 'de':
                const de = await import('./de');
                translations = de.default;
                break;
            case 'en':
                const en = await import('./en');
                translations = en.default;
                break;
            case 'fr':
                const fr = await import('./fr');
                translations = fr.default;
                break;
            default:
                // Fallback to German if language not found
                const fallback = await import('./de');
                translations = fallback.default;
        }
        
        return translations;
    } catch (error) {
        console.error(`Failed to load language ${language}:`, error);
        // Fallback to German in case of error
        const fallback = await import('./de');
        return fallback.default;
    }
};

// Re-export types
export type { Language, TranslationKeys } from './types'; 