我目前正在从事一个涉及翻译的项目,我正在使用Flutter和Dart语言构建应用程序。
问题是我不知道如何用我的应用程序在dart中翻译文本。
我尝试过使用各种平台,例如google translation API,Firebase,Yandex ...但是我没有钱,这是一个问题。
所以我尝试了此https://docs.microsoft.com/fr-fr/azure//cognitive-services/translator/reference/v3-0-translate#request-url,但收到了此错误消息{"error":{"code":405000,"message":"The request method is not supported for the requested resource."}}
。
然后我尝试使用dart包:https://pub.dev/packages/localize_and_translate,它起作用了,但是它是要翻译json文件中已有的文本,我需要翻译用户会给我的文本。
我还尝试获取其中一个google翻译请求中的内容,以获取答案而不必手动访问网站,当我尝试分析请求时,我仅获得此链接:https://fonts.googleapis.com/css?lang=fr&family=Product+Sans%7CRoboto:400,700
。
肯定会非常感谢一些帮助或想法。
感谢一切!
您可以使用AWS Translate(一年免费),我已经为我的生产用应用程序创建了一个插件。之前,我在Flutter MethodChannel
上使用了Android本机和IOS本机AWS官方软件包,后来我决定将其打包,以便其他类似的人可以从中获得帮助。
这里是包裹:https://pub.dev/packages/aws_translate
阅读有关AWS翻译的更多信息:https://aws.amazon.com/translate/
这里是一个简单的用法示例:
AwsTranslate awsTranslate = AwsTranslate(
poolId: poolId, // your pool id here
region: Regions.AP_NORTHEAST_2); // your region here
// from parameter is default to ``auto``
String textToTranslate = 'If you press on this text, I can translate this text for you.';
String translated = await awsTranslate.translateText(textToTranslate, to: 'es');
if (!mounted) return;
print(textToTranslate);
setState(() => textToTranslate = translated);
[如果您只想尝试Google翻译(无需登录,但不能在生产应用中使用,请尝试https://pub.dev/packages/translator