def sentences_translate_example_en_to_zh(): result = DeepLTranslator( translate_str=TEST_EN_SENTENCES, target_lang=TranslateLanguageEnum.ZH, translate_mode=TranslateModeType.SENTENCES, ).translate() print(result)
def test_translate_word(): result = DeepLTranslator( translate_str="水印", target_lang=TranslateLanguageEnum.EN, translate_mode=TranslateModeType.WORD, ).translate() assert_equal(result, {"result": "watermark"})
def word_translate_example_zh_to_en(): result = DeepLTranslator( translate_str="水印", target_lang=TranslateLanguageEnum.EN, translate_mode=TranslateModeType.WORD, ).translate() # result: {'result': 'watermark'} print(result)
def word_translate_example_zh_to_ja(): result = DeepLTranslator( translate_str="水印", target_lang=TranslateLanguageEnum.JA, translate_mode=TranslateModeType.WORD, ).translate() # {'result': '透かし'} print(result)
def get_sentences_translate_raw_data(): result = DeepLTranslator( translate_str=TEST_EN_SENTENCES, target_lang=TranslateLanguageEnum.ZH, translate_mode=TranslateModeType.SENTENCES, is_raw_data=True, ).translate() print(result)
def word_translate_example_ja_to_en(): result = DeepLTranslator( translate_str="透かし", source_lang=TranslateLanguageEnum.JA, target_lang=TranslateLanguageEnum.EN, translate_mode=TranslateModeType.WORD, ).translate() # {'result': 'watermark'} print(result)
def get_translate_raw_data_example(): result = DeepLTranslator( translate_str="透かし", source_lang=TranslateLanguageEnum.JA, target_lang=TranslateLanguageEnum.EN, translate_mode=TranslateModeType.WORD, is_raw_data=True, ).translate() # raw data print(result)
def test_translate_sentences(): result = DeepLTranslator( translate_str=TEST_ZH_SENTENCES, target_lang=TranslateLanguageEnum.EN, translate_mode=TranslateModeType.SENTENCES, ).translate() assert_equal( result, { "result": "It was a beautiful day and I went hiking with Xiao Ming." "We met Little Red in the mountains and happily wrote code together." }, )