Skip to content

Script Fails When Translating from Khmer to English (Not using different provider) #102

@mcnamara-charles

Description

@mcnamara-charles

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions