Skip to content

Commit f19eb18

Browse files
committed
chg: [language translation] do not sent unsupported languages to libretranslate
1 parent 65b4587 commit f19eb18

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

bin/lib/Language.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,15 +687,21 @@ def detect(self, content):
687687

688688
def translate(self, content, source=None, target="eng"):
689689
# print(source, target)
690-
if target not in get_translation_languages():
691-
return None
690+
l_languages = get_translation_languages()
691+
if source:
692+
if source not in l_languages:
693+
return None, None
694+
if target not in l_languages:
695+
return None, None
692696
translation = None
693697
if content:
694698
if not source:
695699
source = self.detect(content)
696700
# print(source, content)
697701
if source:
698702
if source != target:
703+
if source not in l_languages:
704+
return None, None
699705
try:
700706
source_iso1 = convert_iso3_code(source)
701707
target_iso1 = convert_iso3_code(target)

0 commit comments

Comments
 (0)