1
0
mirror of https://github.com/chubin/cheat.sh.git synced 2026-06-20 13:16:44 +02:00

Remove defunct i18n support

This commit is contained in:
Anatoli Babenia
2022-12-14 03:09:47 +03:00
parent bae856b963
commit 3ff6de744b
2 changed files with 1 additions and 41 deletions
+1 -37
View File
@@ -12,9 +12,6 @@ import os
import re
from subprocess import Popen, PIPE
from polyglot.detect import Detector
from polyglot.detect.base import UnknownLanguage
from config import CONFIG
from languages_data import SO_NAME
from .upstream import UpstreamAdapter
@@ -83,40 +80,7 @@ class Question(UpstreamAdapter):
topic_words = topic.split()
topic = " ".join(topic_words)
lang = "en"
try:
query_text = topic # " ".join(topic)
query_text = re.sub("^[^/]*/+", "", query_text.rstrip("/"))
query_text = re.sub("/[0-9]+$", "", query_text)
query_text = re.sub("/[0-9]+$", "", query_text)
detector = Detector(query_text)
supposed_lang = detector.languages[0].code
if len(topic_words) > 2 or supposed_lang in [
"az",
"ru",
"uk",
"de",
"fr",
"es",
"it",
"nl",
]:
lang = supposed_lang
if supposed_lang.startswith("zh_") or supposed_lang == "zh":
lang = "zh"
elif supposed_lang.startswith("pt_"):
lang = "pt"
if supposed_lang in ["ja", "ko"]:
lang = supposed_lang
except UnknownLanguage:
print("Unknown language (%s)" % query_text)
if lang != "en":
topic = ["--human-language", lang, topic]
else:
topic = [topic]
topic = [topic]
cmd = [CONFIG["path.internal.bin.upstream"]] + topic
proc = Popen(cmd, stdin=open(os.devnull, "r"), stdout=PIPE, stderr=PIPE)
-4
View File
@@ -7,11 +7,7 @@ dateutils
fuzzywuzzy
redis
colored<1.4.3
langdetect
cffi
polyglot
PyICU
pycld2
colorama
pyyaml
python-Levenshtein