Googletrans

Pywiki
둘러보기로 가기 검색하러 가기

1 개요[편집 | 원본 편집]

구글에서 제공하는 api를 이용한 요청. 무료이고 무제한이다.(언제 막힐진 몰라.)

1.1 사전 준비[편집 | 원본 편집]

과정 설명 방법
설치 그냥 설치하면 구버전이 설치되니, 아래 명령으로 진행하는 걸 권장. pip install googletrans

pip install googletrans==4.0.0-rc1

모듈 호출 from googletrans import Translator

2 기초 사용[편집 | 원본 편집]

의도 설명 방법
언어 지정 언어코드를 통해 어떤 언어에서 어떤 언어로 번역할지 지정한다. translator = Translator('번역할텍스트', src='ko', dest='ja')
번역 번역된 텍스트가 translation 안에 담긴다. translation = translation.text

2.1 언어감지[편집 | 원본 편집]

translator = Translator() # 인스턴트 생성을 먼저 해준다.

detection = translator.detect('こんにちは。')

lang = detection.lang # 감지 정보 중 언어정보만 뽑아낸다.