Spaces:
				
			
			
	
			
			
		Sleeping
		
	
	
	
			
			
	
	
	
	
		
		
		Sleeping
		
	File size: 2,856 Bytes
			
			| 273abe1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | # translations/__init__.py
import logging
from importlib import import_module
logger = logging.getLogger(__name__)
def get_translations(lang_code):
    # Asegurarse de que lang_code sea válido
    if lang_code not in ['es', 'en', 'fr', 'pt']:
        print(f"Invalid lang_code: {lang_code}. Defaulting to 'es'")
        lang_code = 'es'
    try:
        # Importar dinámicamente el módulo de traducción
        translation_module = import_module(f'.{lang_code}', package='translations')
        translations = getattr(translation_module, 'TRANSLATIONS', {})
    except ImportError:
        logger.warning(f"Translation module for {lang_code} not found. Falling back to English.")
        # Importar el módulo de inglés como fallback
        translation_module = import_module('.en', package='translations')
        translations = getattr(translation_module, 'TRANSLATIONS', {})
    def get_text(key, section='COMMON', default=''):
        return translations.get(section, {}).get(key, default)
    return {
        'get_text': get_text,
        **translations.get('COMMON', {}),
        **translations.get('TABS', {}),
        **translations.get('MORPHOSYNTACTIC', {}),
        **translations.get('SEMANTIC', {}),
        **translations.get('DISCOURSE', {}),
        **translations.get('ACTIVITIES', {}),
        **translations.get('FEEDBACK', {}),
        **translations.get('TEXT_TYPES', {}),
        **translations.get('CURRENT_SITUATION', {}),  # Añadir esta línea
        **translations.get('GRAPH_LABELS', {})
    }
# Nueva función para obtener traducciones específicas del landing page
def get_landing_translations(lang_code):
    # Asegurarse de que lang_code sea válido
    if lang_code not in ['es', 'en', 'fr', 'pt']:
        print(f"Invalid lang_code: {lang_code}. Defaulting to 'es'")
        lang_code = 'es'
    try:
        # Importar dinámicamente el módulo de traducción del landing page
        from .landing_translations import LANDING_TRANSLATIONS
        
        # Asegurarse de que el idioma esté disponible, si no usar español como fallback
        if lang_code not in LANDING_TRANSLATIONS:
            logger.warning(f"Landing translations for {lang_code} not found. Falling back to Spanish.")
            lang_code = 'es'
            
        return LANDING_TRANSLATIONS[lang_code]
    except ImportError:
        logger.warning("Landing translations module not found. Using default translations.")
        # Crear un conjunto mínimo de traducciones por defecto
        return {
            'select_language': 'Select language' if lang_code == 'en' else 'Selecciona tu idioma',
            'login': 'Login' if lang_code == 'en' else 'Iniciar Sesión',
            'register': 'Sign Up' if lang_code == 'en' else 'Registrarse',
            # Añadir más traducciones por defecto si es necesario
        }
 | 
