terryyin / terryyin/translate-python
Script Fails When Translating from Khmer to English (Not using different provider)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 759
- Forks
- 152
- PR merge metrics
- No merged PRs in 30d
Description
When attempting to translate some example text from Khmer to english, the translator fails. It's able to translate English into Khmer I fail to see why it wouldn't be able to do both. Here's the test code that failed
translator= Translator(from_lang="Khmer", to_lang="English")
a_translated = translator.translate("ខ្ញខ្ញុំស្រឡាញ់មាន់")
print(a_translated)
and here's the ensuing error
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\translate\translate.py", line 45, in <genexpr>
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\translate\providers\mymemory_translated.py", line 49, in get_translation
next_best_match = next(match for match in matches)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
StopIteration
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "hidden-for-patent-reasons", line 42, in <module>
a_translated = translator.translate("ខ្ញខ្ញុំស្រឡាញ់មាន់")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\translate\translate.py", line 45, in translate
return ' '.join(self.provider.get_translation(text_wraped) for text_wraped in text_list)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: generator raised StopIteration
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 Khmer-to-English example, then inspect translate/translate.py and providers/mymemory_translated.py, especially the failing match lookup shown in the traceback. Check the provider response for this language pair and run the existing test suite if available. Done means the example returns a translation without RuntimeError while preserving other provider behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- localization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100