Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
谷歌翻译, 支持 APIKEY
pip install -U pygtrans
pip install git+ssh://git@github.com/foyoux/pygtrans.git
pip install git+https://github.com/foyoux/pygtrans.git
from pygtrans import Translate
client = Translate(proxies={'https': 'http://localhost:10809'})
# 检测语言
text = client.detect('Answer the question.')
assert text.language == 'en'
# 翻译句子
text = client.translate('Look at these pictures and answer the questions.')
assert text.translatedText == '看这些图片,回答问题。'
# 批量翻译
texts = client.translate([
'Good morning. What can I do for you?',
'Read aloud and underline the sentences about booking a flight.',
'May I have your name and telephone number?'
])
assert [text.translatedText for text in texts] == [
'早上好。我能为你做什么?',
'大声朗读并在有关预订航班的句子下划线。',
'可以给我你的名字和电话号码吗?'
]
# 翻译到日语
text = client.translate('请多多指教', target='ja')
assert text.translatedText == 'お知らせ下さい'
# 翻译到韩语
text = client.translate('请多多指教', target='ko')
assert text.translatedText == '조언 부탁드립니다'
# 文本到语音
tts = client.tts('やめて', target='ja')
open('やめて.mp3', 'wb').write(tts)
pygtrans
中包含两个翻译模块
Translate
的最佳实践:
http
代理:Translate(proxies={"https": "http://localhost:10809"})
socks5
代理: Translate(proxies={"https": "socks5://localhost:10808"})
FAQs
Google Translate, support APIKEY
We found that pygtrans demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.