hyeonga_code
파이선 웹구축_장고_기초12_번역 기능 googletrans 본문
- 번역 기능
- pip install googletrans==4.0.0-rc1
1. 번역 기능 설치
터미널
=====
'''
(mysite) C:\mysite\앱이름> pip install googletrans==4.0.0-rc1
Collecting googletrans==4.0.0-rc1
Using cached googletrans-4.0.0rc1.tar.gz (20 kB)
Preparing metadata (setup.py) ... done
Collecting httpx==0.13.3
Using cached httpx-0.13.3-py3-none-any.whl (55 kB)
Collecting certifi
Using cached certifi-2022.12.7-py3-none-any.whl (155 kB)
Collecting hstspreload
Using cached hstspreload-2023.1.1-py3-none-any.whl (1.5 MB)
Collecting sniffio
Using cached sniffio-1.3.0-py3-none-any.whl (10 kB)
Collecting chardet==3.*
Using cached chardet-3.0.4-py2.py3-none-any.whl (133 kB)
Collecting idna==2.*
Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting rfc3986<2,>=1.3
Using cached rfc3986-1.5.0-py2.py3-none-any.whl (31 kB)
Collecting httpcore==0.9.*
Using cached httpcore-0.9.1-py3-none-any.whl (42 kB)
Collecting h11<0.10,>=0.8
Using cached h11-0.9.0-py2.py3-none-any.whl (53 kB)
Collecting h2==3.*
Using cached h2-3.2.0-py2.py3-none-any.whl (65 kB)
Collecting hyperframe<6,>=5.2.0
Using cached hyperframe-5.2.0-py2.py3-none-any.whl (12 kB)
Collecting hpack<4,>=3.0
Using cached hpack-3.0.0-py2.py3-none-any.whl (38 kB)
Installing collected packages: rfc3986, hyperframe, hpack, h11, chardet, sniffio, idna, hstspreload, h2, certifi, httpcore, httpx, googletrans
DEPRECATION: googletrans is being installed using the legacy 'setup.py install' method, because it does not have a 'pyproject.toml' and the 'wheel' package is not installed. pip 23.1 will enforce this behaviour change. A possible replacement is to enable the '--use-pep517' option. Discussion can be found at https://github.com/pypa/pip/issues/8559
Running setup.py install for googletrans ... done
Successfully installed certifi-2022.12.7 chardet-3.0.4 googletrans-4.0.0rc1 h11-0.9.0 h2-3.2.0 hpack-3.0.0 hstspreload-2023.1.1 httpcore-0.9.1 httpx-0.13.3 hyperframe-5.2.0 idna-2.10 rfc3986-1.5.0 sniffio-1.3.0
[notice] A new release of pip available: 22.3.1 -> 23.0.1
[notice] To update, run: python.exe -m pip install --upgrade pip
'''
2. 실행해보기 <trans> > 'test.py'
'test.py'
=====
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
import googletrans
from googletrans import Translator
text1 = "Hello welcome to my website!"
tr = Translator()
#_ 객체 생성(번역가)
print(tr.detect(text1))
trans1 = tr.translate(text1, src='en', dest='ja')
#_ 영어를 일본어로 번역
trans1 = tr.translate(text1, src='en', dest='ko')
#_ 영어를 한국어로 번역
print("English to Japanese: ", trans1.text)
|
cs |
- 밑줄 > 못알아 보겠다. > 인터프리터 변경해주기
>> 실행 시,
: English to Japanese: こんにちは私のウェブサイトへようこそ!
'Python_Django' 카테고리의 다른 글
파이선 웹구축_장고_기초13_음성 기능 gTTs (0) | 2023.07.02 |
---|---|
파이선 웹구축_장고_기초11_장고 연산 (0) | 2023.06.30 |
파이선 웹구축_장고_기초10_다량의 테이블 데이터 생성 (0) | 2023.06.29 |
파이선 웹구축_장고_36_알림 경고창 팝업 띄우기 (0) | 2023.06.29 |
파이선 웹구축_장고_기초09_데이터 관계 (0) | 2023.06.28 |