Google translation

Google Translation for using Google API key easily.

Pub package

Github

First announcement

Google Translation package currently only support for basic addition of Google Translation API.

Advanced addition will be supported later.

Learn more about Google Translation and the different between basic and advanced addition here.

Get started

Setup API Key

When using Google Translation API, you need to setup Google Translation API key.

Install

Add google_translation to your pubspec dependencies.

Usage

Configuration

Setup Google Translation API for once.

final googleTranslation = GoogleTranslation();
googleTranslation.setupAPIKey("YOUR_GOOGLE_API_KEY");

Google Translation API can update or overwrite when call function anytime.

Simple Translation

For translate text

final result = await googleTranslation.simpleTextTranslate(
    inputText: "TEXT_NEED_TRANSLATE",
    sourceLanguage: "en", // optional
    targetLanguage: "vi",
    googleAPIKey: "YOUR_GOOGLE_API_KEY", // optional. If already setup above then doesn't need
);

print("Result: $result"); // output value

Language Detection

For language detection, get list detect languages

final listDetectLanguages = await googleTranslation.simpleTextDetectLanguages(
    inputText: "TEXT_NEED_TO_DETECT_LANGUAGE",
    googleAPIKey: "YOUR_GOOGLE_API_KEY", // optional. If already setup above then doesn't need
);

print("List detect languages: $listDetectLanguages"); // output value

Get Language Supported

There are two methods support

  1. Get Supported language at default
final supportLanguages = await googleTranslation.getListSupportLanguages(
   googleAPIKey: "YOUR_GOOGLE_API_KEY", // optional. If already setup above then doesn't need
);

print("List support languages: $supportLanguages"); // output value
  1. Get Supported language at specific target localization
final supportLanguages = await googleTranslation.getListSupportLanguages(
    targetLanguage: "en", // Define this
    googleAPIKey: "YOUR_GOOGLE_API_KEY", // optional. If already setup above then doesn't need
);

print("List support languages: $supportLanguages"); // output value

Read more

Libraries

google_translation