This package allows you to quickly set up Microsoft Azure Translator for Flutter.
Features
- Implement translation out of the box
- Suitable for languages like Cantonese that does not work well in Google translate
- All you need is your
Ocp-Apim-Subscription-Key
&Ocp-Apim-Subscription-Region
from Azure
Getting started
Head our to this link tocreate your Azure account and setup translator resources: https://learn.microsoft.com/en-gb/azure/cognitive-services/Translator/create-translator-resource
Usage
Initialize the translator by passing the subscriptKey andsubscriptionRegion
MicrosoftAzureTranslator.initialize(dotenv.env['MICROSOFT_AZURE_SUBSCRIPTION_KEY']!, dotenv.env['MICROSOFT_AZURE_SUBSCRIPTION_REGION']!);
List<dynamic>? translated = await MicrosoftAzureTranslator.instance.translate("how are you?", "en", "yue");
if (translated != null) {
print('received translation from package..');
print(translated);
translated.forEach((translatedItem) {
print(translatedItem);
print(translatedItem["text"]);
});
}
Additional information
TODO:
- Allow passing a list of languages codes to be translated at once