Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove defunct i18n support #372

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 1 addition & 29 deletions lib/adapter/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
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
Expand Down Expand Up @@ -81,32 +78,7 @@ def _get_page(self, topic, request_options=None):
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)
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ dateutils
fuzzywuzzy
redis
colored<1.4.3
langdetect
cffi
polyglot
PyICU
pycld2
colorama
pyyaml
python-Levenshtein
Expand Down