首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Google翻译器不使用用英语编写的Gujrati语言。

Google翻译器不使用用英语编写的Gujrati语言。
EN

Stack Overflow用户
提问于 2022-01-19 05:52:50
回答 3查看 262关注 0票数 1
代码语言:javascript
复制
# google-translate version 3.6.1

from os import environ
import os

from google.cloud import translate

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = r"/multilingual-bot.json"

project_id = 'multilingual-bot'

assert project_id
parent = f"projects/{project_id}"
client = translate.TranslationServiceClient()
client.get_supported_languages(parent=parent, display_language_code="en")

sample_text = "kevu chale che badhu"
target_language_code = "en"
lan_response = client.detect_language(parent=parent, content=sample_text)
response = client.translate_text(contents=[sample_text],source_language_code='gu',target_language_code=target_language_code,parent=parent)
for translation in response.translations:
    print(translation.translated_text)
print(lan_response)

当我在sample_text中传递"kevu chale che badhu“时,输出保持不变,但是如果我们用根语言(即”કેવુચલેછેબધુ“)更改它,它将返回正确的输出。我也将源代码更改为gu,但是没有什么改变。

EN

回答 3

Stack Overflow用户

发布于 2022-01-19 12:05:13

目前,不支持将用拉丁文字母表编写的任何语言转换为目标语言。在这个问题跟踪器中,印地语也提出了同样的问题。如果您想拥有古吉拉特语的这个特性--请使用这个链接.However提出一个特性请求--我们目前不能提供ETA,但是您可以通过引用这个链接来“调整”这个问题来接收自动更新并给它提供支持。

票数 1
EN

Stack Overflow用户

发布于 2022-01-24 19:34:12

我能找到的唯一已知的解决方案,我已经成功地实现了(处理印地语和其他语言),就是音译输入。

我个人认为Google的回答是不受支持的,因为从拉丁文输入字符返回的目标语言(在语音上相当于输入者想要的语音)是实际的语言。因此,在印地语中检测到"HI“,但返回的翻译与输入相同。如果谷歌能够从音译的拉丁语字符中检测出它的印地语,那么为什么不直接返回结果呢?

代码语言:javascript
复制
Steps to work around:
1. translate through translate-api as normal.  Use the latin characters as the inputs.
2. receive the results from the the translate, and ignore the returned translation. (It will be the same as the input latin). Collect the targetLanguageDetected field, and save this.
3. call google's (deprecated but still supported) transliterate interface, with the input language (received from step 2) and the same original latin character inputs (URL is: https://inputtools.google.com/request?text=${srcMessage}&itc=${srclang}-t-i0-und&num=${numChoices}&cp=0&cs=1&ie=utf-8&oe=utf-8&app=demopage) - srcMessage is the original latin character text, srclang is the output from step 2, and numchoices is the number of "suggestions" that are generated from the input.
4. re run step 1, with the output from step 3 (the "HI" characters, or whatever alphabet is returned)

谷歌过去允许在不需要翻译成本的情况下进行检测,但现在已经不是这样了。

此外,Google的API在这种行为中是不一致的。例如,如果我输入俄语音译:“女贞”,我会得到“你好”。

票数 0
EN

Stack Overflow用户

发布于 2022-01-19 06:23:12

嗨,google云控制台是为英语制作的,你不是完全管理它,它只是你管理的例子,我试着关闭我的google,我尝试过sudo,我试过sudo,并且它的工作方式是相同的,使用sudo apt下载语言包,如果sudo su不工作的话,使用sudo来安装sudo,所以这意味着google不想让你这么做。

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70765855

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档