TenshiTranslator.Translator.OnlineTranslator module¶
- class TenshiTranslator.Translator.OnlineTranslator.OnlineTranslator(outputOption: OutputFormat, preprocessGlossary: Glossary, postProcessGlossary: Glossary, timeoutWait: int = 315)¶
Bases:
Translator
Translator that translates by automating sugoitranslator.com using selenium
As sugoi translator has a rate limit, this translator automatically waits for the timeout to end before resuming. The advantage of this translator is that it is free and does not require any setup. However, it is both the slowest and the least accurate as it uses an older model and has a character limit of 100 characters per request. Long sentences will be split into multiple requests, and contexts will not be taken into account.
- Parameters:
outputOption – the output format to use
preprocessGlossary – the glossary to use for preprocessing
postProcessGlossary – the glossary to use for postprocessing
timeoutWait – the time to wait in seconds when a timeout is detected, defaults to 315 seconds
- initWebsite()¶
Initializes the website by opening the site then swapping the language to japanese
- japaneseToEnglish(japanese: str | list[str]) str ¶
Translates a string or a list of strings from japanese to english using the sugoitranslator website and selenium
- Parameters:
japanese – the string or list of strings to be translated
- Returns:
the translated string
- translate(inputFilePath: str)¶
Translates a file and writes to inputFilePath-Translated.txt
- Parameters:
inputFilePath – path to the file to be translated
- Raises:
FileNotFoundError if the file is not found
- Raises:
Exception if any other error occurs