Skip to content

Releases: Avimitin/deepl-rs

Release v0.6.0

27 Feb 17:45
edeec86
Compare
Choose a tag to compare

Breaking change

  • Fix incorrect implementation of glossary API

Migration guide v0.5.1 -> v0.6.0

In the previous implementation, I misunderstood the DeepL API document and implemented a single entry only Glossary API. After this release, glossary APIs are now all supporting list of entries.

+   let my_entries = vec![("Hello", "Guten Tag"), ("Bye", "Auf Wiedersehen")];
+   // let my_entries = HashMap::from([("Hello", "Guten Tag"), ("Bye", "Auf Wiedersehen")]);
    let resp = deepl
        .create_glossary("My Glossary")
-       .source("Hello", Lang::EN)
-       .target("Guten Tag", Lang::DE)
+       .source_lang(Lang::EN)
+       .target_lang(Lang::DE)
+       .entries(&my_entries)
        .format(EntriesFormat::CSV) // This field is optional, we will use TSV as default.
        .send()
        .await
        .unwrap();

Release v0.5.0

21 Feb 09:06
67bb917
Compare
Choose a tag to compare

Breaking change

  • Add type constraint for glossary APIs

v0.4.6 -> v0.5.0 migration guide

deepl
    .create_glossary("My Glossary")
-   .source("Hello", "en")
-   .target("Guten Tag", "de")
+   .source("Hello", Lang::EN)
+   .target("Guten Tag", Lang::DE)
    .format(EntriesFormat::CSV) // This field is optional, we will use TSV as default.
    .send()
    .await
    .unwrap();

Release v0.4.6

13 Feb 16:12
26aad02
Compare
Choose a tag to compare

Add support for all glossaries related APIs. This library is now completely support all DeepL APIs.

Warning

The Glossaries APIs use a different language code than other APIs, it is hard and disgusting to implement two different deserialization logic for the lang enum. So for Glossaries APIs, I sacrifice a bit and fallback to using String type for source_lang and target_lang fields.

v0.4.0

26 Jan 05:34
97d12f6
Compare
Choose a tag to compare

This version implement auto send and breaks all the old API call.

v0.3.0 => v0.4.0 migration guide

  • API creation
// OLD
let api = DeepLApi::new("key", true);

// NEW
let api = DeepLApi::with("key").is_pro(true).new();
let api = DeepLApi::with("key").new();
  • Translate Text
// OLD
let settings = TranslateTextProp::build()
	.target_lang(Lang::DE)
	.build();
let response = api.translate("Hello World", &settings).await.unwrap();

// NEW
let response = api.translate_text("Hello World", Lang::DE).await.unwrap();

//----------------------------------------

let origin = "Hello World <keep>This will stay exactly the way it was</keep>";

// OLD
let settings = TranslateTextProp::builder()
    .source_lang(Lang::EN)
    .target_lang(Lang::DE)
    .ignore_tags(vec!["keep".to_owned()])
    .tag_handling(TagHandling::Xml)
    .build();
let response = api.translate(origin, &settings).await.unwrap();

// NEW
let response = api
    .translate_text(origin, Lang::DE)
    .source_lang(Lang::EN)
    .ignore_tags(vec!["keep".to_owned()])
    .tag_handling(TagHandling::Xml)
    .await
    .unwrap();
  • Translate Document
// OLD
let upload_option = UploadDocumentProp::builder()
    .source_lang(Lang::EN_GB)
    .target_lang(Lang::ZH)
    .file_path("./hamlet.txt")
    .filename("Hamlet.txt")
    .formality(Formality::Default)
    .glossary_id("def3a26b-3e84-45b3-84ae-0c0aaf3525f7")
    .build();
let response = api.upload_document(upload_option).await.unwrap();

// NEW
let filepath = std::path::PathBuf::from("./hamlet.txt");
let response = api.upload_document(&filepath, Lang::ZH)
        .source_lang(Lang::EN_GB)
        .filename("Hamlet.txt")
        .formality(Formality::Default)
        .glossary_id("def3a26b-3e84-45b3-84ae-0c0aaf3525f7")
        .await
        .unwrap();

Changed

  • (BREAKING) Implement auto send for all endpoint
  • (BREAKING) DeepLApi implementation is now separated to multiple endpoint file
  • (BREAKING) DeepLApiResponse is now renamed to TranslateTextResp
  • (BREAKING) DeepLApi is now init by ::with() function and build by .new() function
  • Using docx-rs to parse document content for testing

v0.3.0

10 Jan 10:18
53bb281
Compare
Choose a tag to compare

BREAKING CHANGE

  • Lang::from is removed as it violate the naming convention, use the Lang::try_from provided by TryFrom trait instead.

v0.2.0->v0.3.0 migrate guide

let code = "EN-US";

// v0.2.0
let lang = match Lang::from(code) {
     Ok(lang) => lang,
     Err(err) => panic!()
}

//v0.3.0
let lang = match Lang::try_from(code) {
     Ok(lang) => lang,
     Err(err) => panic!()
}

v0.2.0

08 Jan 07:20
8e0c142
Compare
Choose a tag to compare

v0.2.0 breaks the DeepLApi::translate method. It only accept TranslateTextProp argument now. Please read the v0.2.0 document for the new changes.

v0.1 => v0.2 migration guide

// replacing this
api.translate("Hello World", None, Lang::ZH)

// with this
let props = TranslateTextProp::builder().target_lang(Lang::ZH).build();
api.translate("Hello World", &props);

Changelogs

  • Implement all DeepL options for the text translation endpoint (#11 by @seijikun)
  • Correct all the typo (*Reponse -> *Response)
  • Add builder for DeepLApi
  • Re-export the reqwest crate
  • [BREAK] merge the translate function and translate_advanced function introduced in #11
  • Update document

v0.1.6

02 Dec 15:24
Compare
Choose a tag to compare

Fix

  • Fix the fail to download translated document issue

Changes

  • [BREAK] UploadDocumentProp now accpect AsRef<Path> instead of &str to have more generic path options.
  • [BREAK] download_argument now take only an output paramenter to specify the download path

v0.1.3

29 Nov 11:17
a319e1f
Compare
Choose a tag to compare

Added

  • Add support for the upload document API(#2 #4)
  • Add more language variants (#3)
  • Add support for the pro version API

v0.1.2

20 Sep 07:11
6ad8b25
Compare
Choose a tag to compare
  • Add get_usage() api to get current API usage
  • Replace anyhow return with thiserror