示例#1
0
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)
示例#2
0
def test_translate_word():
    result = DeepLTranslator(
        translate_str="水印",
        target_lang=TranslateLanguageEnum.EN,
        translate_mode=TranslateModeType.WORD,
    ).translate()

    assert_equal(result, {"result": "watermark"})
示例#3
0
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)
示例#4
0
def word_translate_example_zh_to_ja():
    result = DeepLTranslator(
        translate_str="水印",
        target_lang=TranslateLanguageEnum.JA,
        translate_mode=TranslateModeType.WORD,
    ).translate()

    # {'result': '透かし'}
    print(result)
示例#5
0
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)
示例#6
0
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)
示例#7
0
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)
示例#8
0
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."
        },
    )