android - 在 android studio 中将所有文本视图翻译成其他语言
问题描述
我想通过从菜单中选择一种语言将我的 android 应用程序的所有文本视图翻译成其他语言。有什么翻译的方法吗?我听说我们可以使用微软文本翻译器进行翻译。但是不知道怎么用。请帮我。
解决方案
是的 !您可以使用 Azure 翻译器来实现您的目标。
高层工作如下:
Azure 翻译器支持 90 种语言和方言。你可以参考这个来访问语言列表。
https://docs.microsoft.com/en-us/azure/cognitive-services/translator/language-support
如何使用 :
第一步是获得订阅 - 如果您想先尝试,请使用以下链接:
https://azure.microsoft.com/en-in/free/cognitive-services/
第 1 步: 创建翻译资源:https ://ms.portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation
步骤 2 转到资源并获取 API 密钥。
第 3 步: 您必须使用以下指定的正文、标题来击中端点:
https://api.cognitive.microsofttranslator.com
网址参数:
/translate?api-version=3.0&from=<SourceLang>&to=<TranslationLang>
示例端点: 如果您要从英语翻译成德语:
https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&from=en&to=de&to=it
标题:
Ocp-Apim-Subscription-Key : <The Subscription Key you obtained>
Ocp-Apim-Subscription-Region : The Translator resource region which you would have provided while creating the resource.
身体 :
要翻译的文本应采用以下格式:
[{
'text': 'Hello World!'
}]
回复 :
成功的响应如下所示:
[
{
"translations": [
{
"text": "Hallo Welt!",
"to": "de"
},
{
"text": "Salve, mondo!",
"to": "it"
}
]
}
]
有关详细信息,请参阅此快速入门。
推荐阅读
- python - 为什么 swifter 比 vanilla df.apply 慢?
- python - 如何在 Jupyter Lab 中自定义键盘快捷键以运行当前行或选定文本?
- android - 向 Room Db 插入数据时出现 ConcurrentModificationException
- css - 如何删除导航栏上按钮之间的空格?
- c# - 如何对编号列表进行排序
- css - 由于溢出滚动触摸css,表响应“中断”模式内部
- android - Android:ConcurrentModificationException 错误
- python - PYTHON AUTH0 POST REQUEST:无效的请求负载 JSON 格式
- swift - 调用我自己的 API 到我的移动应用程序
- google-maps - 如何将热图添加到 Flutter 移动应用程序