deepl 0.0.2 copy "deepl: ^0.0.2" to clipboard
deepl: ^0.0.2 copied to clipboard

An inofficial dart library that calls the DeepL API

deepl-dart #

This is an inofficial library that accesses the DeepL API.

Install #

Put deepl: <latest version> into your pubspec.yaml or call dart pub add deepl or flutter pub add deepl, respectively.

Usage #

Create an instance with

var deeplApi = DeepLApi.fromAuthKey(<your API key>);

and access the API through the namespaces e.g.

var translation = (await deepl.translations.translateText(
    options: TranslateTextRequestOptionsBuilder.simple(
      text: 'Hello',
      target: TargetLanguage.ES,
    ).build(),
  ))
      .first;
  print(
      'Detected language: ${translation.detectedLanguage?.name}, translation: ${translation.text}');

Translating Documents

To translate a document, you must first upload it with

var document = await deepl.documents.uploadDocument(
    options: TranslateDocumentRequestOptionsBuilder(
      filename: '<your_filename>',
      target: TargetLanguage.ES,
    ).build(),
  ));

If it is a large document, you could check its translation status with

var status = await deepl.document.status(document);
print('Status: ${status.key}'');
// works only if `status.key == TranslationStatus.translating`
print('Estd. seconds: ${(status.value as StatusTranslating).estimatedSeconds}');

and finally download it with

var file = await deepl.document.downloadDocument(document, '<your_translated_filename>');

Supported endpoints #

  • ✅ Translating documents
    • ✅ Pploading files
    • ✅ Checking file status
    • ✅ Downloading document
  • ✅ Translating text
  • ✅ Glossaries
  • ✅ Tranlation quota
0
likes
140
points
50
downloads

Publisher

unverified uploader

Weekly Downloads

An inofficial dart library that calls the DeepL API

Repository (GitHub)

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

csv, http, json_annotation

More

Packages that depend on deepl