Animenosekai / translate

A module grouping multiple translation APIs
GNU Affero General Public License v3.0
515 stars 60 forks source link

Is this project dead? Can't transliterate using most translators... #102

Closed shimizurei closed 2 months ago

shimizurei commented 2 months ago

I'm trying to transliterate some phrases from Japanese to romanized Japanese, but I'm having difficulty. Google seems to be the only one that works. The rest say "unsupported" when using the transliterate option.

from translatepy import Translator
from translatepy.translators.google import GoogleTranslate
from translatepy.translators.yandex import YandexTranslate
from translatepy.translators.bing import BingTranslate
from translatepy.translators.deepl import DeeplTranslate
from translatepy.translators.libre import LibreTranslate
from translatepy.translators.microsoft import MicrosoftTranslate
from translatepy.translators.mymemory import MyMemoryTranslate
from translatepy.translators.reverso import ReversoTranslate
from translatepy.translators.translatecom import TranslateComTranslate

def use_translatepy(text: str, translator: str = "google") -> str:
    tler = Translator()
    match translator:
        case "google":
            tler = GoogleTranslate()
        case "yandex":
            tler = YandexTranslate() # Direction 'ja-ja' is not supported
        case "bing":
            tler = BingTranslate() # translatepy.translators.bing.BingTranslateException: 205 | Unknown error. Error code: 205 (issue: #72)
        case "deepl":
            tler = DeeplTranslate() # no transliterate
        case "libre":
            tler = LibreTranslate() # no transliterate
        case "microsoft":
            tler = MicrosoftTranslate() # raise JSONDecodeError("Expecting value", s, err.value) from None; json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
        case "mymemory":
            tler = MyMemoryTranslate() # no transliterate
        case "reverso":
            tler = ReversoTranslate() # no transliterate
        case "translatecom":
            tler = TranslateComTranslate() # no transliterate
        case _:
            raise ValueError(f"Unknown translator: {translator}")

    return tler.transliterate(text, "Japanese").result.strip()

print(use_translatepy("那々緒の珍道中", 'google')) # -> Nana cho no chin dōchū
ZhymabekRoman commented 2 months ago

No, the project is not dead.

There's a problem with the current implementation of transliteration. By default it only works with translation pairs, like Russian -> Japanese or vice versa. Some translation services support source language transliteration, but I can't say which ones at the moment, possibly Google.

This problem should be fixed in version 3, but for now work on it is on hold.

shimizurei commented 2 months ago

Ok, thanks for the confirmation.

Animenosekai commented 2 months ago

Is this project dead?

It is not. I was studying a lot for almost 2 years but I just finished my last exams yesterday so I will be able to continue working on v3 (#78) (just lemme sleep for some time I'm exhausted 😭)