Spaces:
Running
Running
Update translations/__init__.py
Browse files- translations/__init__.py +29 -2
translations/__init__.py
CHANGED
|
@@ -9,7 +9,7 @@ def get_translations(lang_code):
|
|
| 9 |
if lang_code not in ['es', 'en', 'fr', 'pt']:
|
| 10 |
print(f"Invalid lang_code: {lang_code}. Defaulting to 'es'")
|
| 11 |
lang_code = 'es'
|
| 12 |
-
|
| 13 |
try:
|
| 14 |
# Importar din谩micamente el m贸dulo de traducci贸n
|
| 15 |
translation_module = import_module(f'.{lang_code}', package='translations')
|
|
@@ -34,4 +34,31 @@ def get_translations(lang_code):
|
|
| 34 |
**translations.get('FEEDBACK', {}),
|
| 35 |
**translations.get('TEXT_TYPES', {}),
|
| 36 |
**translations.get('CURRENT_SITUATION', {}) # A帽adir esta l铆nea
|
| 37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
if lang_code not in ['es', 'en', 'fr', 'pt']:
|
| 10 |
print(f"Invalid lang_code: {lang_code}. Defaulting to 'es'")
|
| 11 |
lang_code = 'es'
|
| 12 |
+
|
| 13 |
try:
|
| 14 |
# Importar din谩micamente el m贸dulo de traducci贸n
|
| 15 |
translation_module = import_module(f'.{lang_code}', package='translations')
|
|
|
|
| 34 |
**translations.get('FEEDBACK', {}),
|
| 35 |
**translations.get('TEXT_TYPES', {}),
|
| 36 |
**translations.get('CURRENT_SITUATION', {}) # A帽adir esta l铆nea
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
# Nueva funci贸n para obtener traducciones espec铆ficas del landing page
|
| 40 |
+
def get_landing_translations(lang_code):
|
| 41 |
+
# Asegurarse de que lang_code sea v谩lido
|
| 42 |
+
if lang_code not in ['es', 'en', 'fr', 'pt']:
|
| 43 |
+
print(f"Invalid lang_code: {lang_code}. Defaulting to 'es'")
|
| 44 |
+
lang_code = 'es'
|
| 45 |
+
|
| 46 |
+
try:
|
| 47 |
+
# Importar din谩micamente el m贸dulo de traducci贸n del landing page
|
| 48 |
+
from .landing_translations import LANDING_TRANSLATIONS
|
| 49 |
+
|
| 50 |
+
# Asegurarse de que el idioma est茅 disponible, si no usar espa帽ol como fallback
|
| 51 |
+
if lang_code not in LANDING_TRANSLATIONS:
|
| 52 |
+
logger.warning(f"Landing translations for {lang_code} not found. Falling back to Spanish.")
|
| 53 |
+
lang_code = 'es'
|
| 54 |
+
|
| 55 |
+
return LANDING_TRANSLATIONS[lang_code]
|
| 56 |
+
except ImportError:
|
| 57 |
+
logger.warning("Landing translations module not found. Using default translations.")
|
| 58 |
+
# Crear un conjunto m铆nimo de traducciones por defecto
|
| 59 |
+
return {
|
| 60 |
+
'select_language': 'Select language' if lang_code == 'en' else 'Selecciona tu idioma',
|
| 61 |
+
'login': 'Login' if lang_code == 'en' else 'Iniciar Sesi贸n',
|
| 62 |
+
'register': 'Sign Up' if lang_code == 'en' else 'Registrarse',
|
| 63 |
+
# A帽adir m谩s traducciones por defecto si es necesario
|
| 64 |
+
}
|