Skip to content

Commit 65999f8

Browse files
committed
add new requirement
1 parent 33ca100 commit 65999f8

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
ply==3.11
22
PyYAML==5.4.1
33
Unidecode==1.3.2
4+
argostranslate==1.9.6

universalpython/filters/translate/__init__.py

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
def argos_translator(text, source):
2+
if not argos_translate_initialized:
3+
initialize_argos_translate()
4+
5+
if argos_translator is not None:
6+
try:
7+
return argos_translator.translate(text)
8+
except Exception as e:
9+
print(f"Warning: Translation failed - {str(e)}")
10+
return text
11+
return text
File renamed without changes.

universalpython/modes/lex.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -252,14 +252,14 @@ def t_ID(t):
252252
# print ("Value is:", t.value)
253253
# ------------- Debugging ---------------
254254

255-
256255
if args['translate']:
257-
if t.type == 'ID':
258-
t.value = unidecode(t.value)
259-
260-
261-
262-
256+
if args['translate'] == 'argostranslate':
257+
from universalpython.filters.translate.argos_translator import argos_translator
258+
if t.type == 'ID':
259+
t.value = argostranslate(t.value)
260+
else:
261+
if t.type == 'ID':
262+
t.value = unidecode(t.value)
263263
return t
264264

265265
if args["reverse"]:

0 commit comments

Comments
 (0)