Kakaotrans
Unofficial python API for Kakao translate service.
Installation
$ pip install kakaotrans
Usage
Basic Usage
>>> from kakaotrans import Translator
>>> translator = Translator()
>>> translator.translate("Try your best rather than be the best.")
# '์ต๊ณ ๊ฐ ๋๊ธฐ๋ณด๋ค๋ ์ต์ ์ ๋คํ๋ผ.'
>>> translator.translate("์ต๊ณ ๊ฐ ๋๊ธฐ๋ณด๋ค๋ ์ต์ ์ ๋คํ๋ผ.", src='kr', tgt='de')
# 'Tun Sie Ihr Bestes, anstatt das Beste zu sein.'
Separate the query into multiple sentences
Translation query might include multiple sentences. If you set separate_lines=True, translator will automatically separate the query and return the list of multiple sentences.
from kakaotrans import Translator
translator = Translator()
translator.translate("""์ง๋ํด 3์ ์คํํ ์นด์นด์คํก ์ฃผ๋ฌธํ๊ธฐ๋ ํ์ฌ๊น์ง ์ฝ 250๋ง๋ช
์ ํ์์ ํ๋ณดํ๋ค.
์ ๊ตญ๋ฏผ์๊ฒ ์น์ํ ์นด์นด์คํก UI๋ฅผ ํ์ฉํ๊ธฐ ๋๋ฌธ์ ๋ณ๋์ ์ฑ์ ์ค์นํ ํ์ ์์ด ์นด์นด์คํก ๋ด์์ ๋ชจ๋ ๊ณผ์ ์ด ์ด๋ค์ง๋ ๊ฒ์ด ํน์ง์ด๋ค.""",
src='kr', tgt='en', separate_lines=True)
# ['The ordering of KakaoTalk, which opened in March last year, has secured about 2.5 million members to date.', 'Because it uses KakaoTalk UI, which is familiar to the whole nation, it is characterized by all the processes in KakaoTalk without having to install a separate app.']
Save translated result as file
>>> from kakaotrans import Translator
>>> translator = Translator()
>>> translator.translate("Try your best rather than be the best.", save_as_file=True, file_name='result.txt')