搜尋套件、儲存庫與 APP 分類

套件詳情v1.0.1

translator_plus

一個免費且無限制的 Dart Google 翻譯 API。您可使用它來翻譯字串和文字,以供教育用途。

AndroidiOSWebmacOSWindowsLinux
近 30 天下載
436
喜歡數
19
Pub 分數
145

安裝套件

flutter pub add translator_plus

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

translator_plus 是一個 Dart 套件,提供免費且無限的 Google 翻譯功能存取,讓開發者能夠跨多種語言翻譯文字和字串。專為教育用途設計,支援所有主要平台,包括 Android、iOS、Web、macOS、Windows 和 Linux。此套件簡化了將翻譯功能整合至 Flutter 應用程式的過程,無需 API 金鑰或複雜設定。非常適合學習國際化概念或以最低開銷建立多語系應用程式。

適用情境

  • 即時翻譯應用內容
  • 涉及語言轉換的教育專案
  • 構建多語言原型
  • 本地化面向用戶的內容
  • 支援非英文使用者的應用程式

主要特色

  • 無需 API 金鑰
  • 免費且無限使用
  • 跨平台支援
  • 文字翻譯的簡單 API
  • 內建語言檢測

適合對象

  • 初學者Flutter開發者
  • 教育應用程式
  • 原型設計多語言應用程式
  • 面向全球受眾的應用
  • 需要快速翻譯整合的項目

使用建議

  • 僅用於教育目的
  • 不建議用於高流量的生產應用程式
  • 依賴 Google 翻譯的公共介面
  • 可能受 Google 的速率限制或變更影響
  • 對翻譯品質的控制有限

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

translator_plus

Free Google Translate API for Dart

See it in pub: https://pub.dev/packages/translator_plus
and GitHub: https://github.com/HusamAwad2001/translator_plus

Usage

void main() async {
  final translator = GoogleTranslator();

  final input = "Здравствуйте. Ты в порядке?";

  translator.translate(input, from: 'ru', to: 'en').then(print);
  // prints Hello. Are you okay?
  
  var translation = await translator.translate("Dart is very cool!", to: 'pl');
  print(translation);
  // prints Dart jest bardzo fajny!

  print(await "example".translate(to: 'pt'));
  // prints exemplo
}

 

Using translate method passing the args from and to designates the language from text you're typing and the language to be translated

translator.translate("I love Brazil!", from: 'en', to: 'pt').then((s) {
    print(s);
  }); 
  // prints Eu amo o Brasil!

 

or you can omit from language and it'll auto-detect the language of source text

translator.translate("Hello", to: 'es').then(print);
// prints Hola

 

and also pass the value to a var using await

var translation = await translator.translate("I would buy a car, if I had money.", from: 'en', to: 'it');
print(translation);
// prints Vorrei comprare una macchina, se avessi i soldi.

 

The returned value is a Translation object which holds the translation stuff

var translation = await translator.translate('Translation', from: 'en', to: 'es');
print('${translation.source} (${translation.sourceLanguage}) == ${translation.text} (${translation.targetLanguage})');

// prints Translation (English) == Traducción (Spanish)

 

You can use the extension method directly on the string too

print(await "example".translate(to: 'pt'));
// prints exemplo

 

There is translateAndPrint method that prints directly

translator.translateAndPrint("This means 'testing' in chinese", to: 'zh-cn');
// prints 这意味着用中文'测试'

 

API

For full API docs take a look at https://pub.dev/documentation/translator_plus/latest/

License

MIT License

Copyright © 2023 Husam Dahliz

Disclaimer

This package is developed for educational purposes only. Do not depend on this package as it may break anytime as it is based on crawling the Google Translate website. Consider buying Official Google Translate API for other types of usage.

所屬分類

依賴

依賴清單 1 項

原始碼儲存庫

使用此套件的專案