AIdeaText commited on
Commit
7b7b1d8
verified
1 Parent(s): 16819da

Update translations/__init__.py

Browse files
Files changed (1) hide show
  1. translations/__init__.py +36 -34
translations/__init__.py CHANGED
@@ -1,35 +1,37 @@
1
- # translations/__init__.py
2
- import logging
3
- from importlib import import_module
4
-
5
- logger = logging.getLogger(__name__)
6
-
7
- def get_translations(lang_code):
8
- # Asegurarse de que lang_code sea v谩lido
9
- if lang_code not in ['es', 'en', 'fr']:
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')
16
- translations = getattr(translation_module, 'TRANSLATIONS', {})
17
- except ImportError:
18
- logger.warning(f"Translation module for {lang_code} not found. Falling back to English.")
19
- # Importar el m贸dulo de ingl茅s como fallback
20
- translation_module = import_module('.en', package='translations')
21
- translations = getattr(translation_module, 'TRANSLATIONS', {})
22
-
23
- def get_text(key, section='COMMON', default=''):
24
- return translations.get(section, {}).get(key, default)
25
-
26
- return {
27
- 'get_text': get_text,
28
- **translations.get('COMMON', {}),
29
- **translations.get('TABS', {}),
30
- **translations.get('MORPHOSYNTACTIC', {}),
31
- **translations.get('SEMANTIC', {}),
32
- **translations.get('DISCOURSE', {}),
33
- **translations.get('ACTIVITIES', {}),
34
- **translations.get('FEEDBACK', {})
 
 
35
  }
 
1
+ # translations/__init__.py
2
+ import logging
3
+ from importlib import import_module
4
+
5
+ logger = logging.getLogger(__name__)
6
+
7
+ def get_translations(lang_code):
8
+ # Asegurarse de que lang_code sea v谩lido
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')
16
+ translations = getattr(translation_module, 'TRANSLATIONS', {})
17
+ except ImportError:
18
+ logger.warning(f"Translation module for {lang_code} not found. Falling back to English.")
19
+ # Importar el m贸dulo de ingl茅s como fallback
20
+ translation_module = import_module('.en', package='translations')
21
+ translations = getattr(translation_module, 'TRANSLATIONS', {})
22
+
23
+ def get_text(key, section='COMMON', default=''):
24
+ return translations.get(section, {}).get(key, default)
25
+
26
+ return {
27
+ 'get_text': get_text,
28
+ **translations.get('COMMON', {}),
29
+ **translations.get('TABS', {}),
30
+ **translations.get('MORPHOSYNTACTIC', {}),
31
+ **translations.get('SEMANTIC', {}),
32
+ **translations.get('DISCOURSE', {}),
33
+ **translations.get('ACTIVITIES', {}),
34
+ **translations.get('FEEDBACK', {}),
35
+ **translations.get('TEXT_TYPES', {}),
36
+ **translations.get('CURRENT_SITUATION', {}) # A帽adir esta l铆nea
37
  }