terryyin / terryyin/translate-python
Autodetection fails
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 759
- Forks
- 152
- PR merge metrics
- No merged PRs in 30d
Description
Autodetection seems to fail, even on your example:
$ translate-cli -t zh "This is a pen."
Translation: '' IS AN INVALID SOURCE LANGUAGE . EXAMPLE: LANGPAIR=EN|IT USING 2 LETTER ISO OR RFC3066 LIKE ZH-CN. ALMOST ALL LANGUAGES SUPPORTED BUT SOME MAY HAVE NO CONTENT
-------------------------
Translated by: MyMemory
Also explicitly asking for autodetection fails:
$ translate-cli -f autodetect -t zh "This is a pen."
$ translate-cli -f 'autodetect' -t zh "This is a pen."
It comes up with the same result, for any target language. Only entering a valid language identifier for source language explicitly instead works as expected:
$ translate-cli -f en -t zh "This is a pen."
Translation: 这是一支笔
-------------------------
Translated by: MyMemory
Trying to use a different service provider fails completely:
$ translate-cli -p deepl -f autodetect -t zh "This is a pen."
Traceback (most recent call last):
File "/home/demo/.local/bin/translate-cli", line 6, in <module>
from translate.__main__ import cli
File "/home/demo/.local/lib/python2.7/site-packages/translate/__main__.py", line 6, in <module>
main()
File "/home/demo/.local/lib/python2.7/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/demo/.local/lib/python2.7/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/demo/.local/lib/python2.7/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/demo/.local/lib/python2.7/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/demo/.local/lib/python2.7/site-packages/translate/main.py", line 159, in main
translator = Translator(**kwargs)
File "/home/demo/.local/lib/python2.7/site-packages/translate/translate.py", line 25, in __init__
'Please check providers list bellow: {!r}'.format(self.available_providers)
translate.exceptions.InvalidProviderError: Provider class invalid. Please check providers list bellow: ['microsoft', 'mymemory']
Any idea what could cause all this? Maybe the install errors I encountered could cause it?
$ pip install translate
[...everything fine until:]
Building wheels for collected packages: filelock, scandir
Running setup.py bdist_wheel for filelock ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-snvHIF/filelock/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-HPe58C --python-tag cp27:
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for filelock
Running setup.py clean for filelock
Running setup.py bdist_wheel for scandir ... error
Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-snvHIF/scandir/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-8EKBmy --python-tag cp27:
/usr/lib/python2.7/distutils/extension.py:133: UserWarning: Unknown Extension options: 'optional'
warnings.warn(msg)
usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: -c --help [cmd1 cmd2 ...]
or: -c --help-commands
or: -c cmd --help
error: invalid command 'bdist_wheel'
----------------------------------------
Failed building wheel for scandir
Running setup.py clean for scandir
Failed to build filelock scandir
Installing collected packages: click, contextlib2, zipp, six, scandir, pathlib2, configparser, importlib-metadata, pyparsing, packaging, filelock, pluggy, appdirs, distlib, typing, singledispatch, importlib-resources, virtualenv, toml, py, tox, cfgv, pyyaml, aspy.yaml, nodeenv, futures, identify, pre-commit, certifi, urllib3, idna, requests, translate
Running setup.py install for scandir ... done
Running setup.py install for filelock ... done
Successfully installed appdirs-1.4.4 aspy.yaml-1.3.0 certifi-2020.12.5 cfgv-2.0.1 click-7.1.2 configparser-4.0.2 contextlib2-0.6.0.post1 distlib-0.3.1 filelock-3.0.12 futures-3.3.0 identify-1.6.2 idna-2.10 importlib-metadata-2.1.1 importlib-resources-3.3.1 nodeenv-1.6.0 packaging-20.9 pathlib2-2.3.5 pluggy-0.13.1 pre-commit-1.21.0 py-1.10.0 pyparsing-2.4.7 pyyaml-5.4.1 requests-2.25.1 scandir-1.10.0 singledispatch-3.6.1 six-1.15.0 toml-0.10.2 tox-3.23.0 translate-3.5.0 typing-3.7.4.3 urllib3-1.26.4 virtualenv-20.4.4 zipp-1.2.0
Python 2.7.16
pip 18.1 from /usr/lib/python2.7/dist-packages/pip (python 2.7)
P.S.: Many thanks for this great commandline tool!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the autodetection and provider failures with the commands in the report, then start at translate/main.py and translate/main.py, following translator construction into translate/translate.py. Check how the source language and provider are validated and how the available providers are selected. Done means autodetection works for the shown translation and invalid provider handling is consistent with the supported provider list.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100