0 purchases
deepl
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>);
copied to clipboard
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}');
copied to clipboard
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(),
));
copied to clipboard
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}');
copied to clipboard
and finally download it with
var file = await deepl.document.downloadDocument(document, '<your_translated_filename>');
copied to clipboard
Supported endpoints #
✅ Translating documents
✅ Pploading files
✅ Checking file status
✅ Downloading document
✅ Translating text
✅ Glossaries
✅ Tranlation quota
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.