Releases: Avimitin/deepl-rs
Release v0.6.0
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
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
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
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 toTranslateTextResp
- (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
BREAKING CHANGE
- Lang::from is removed as it violate the naming convention, use the
Lang::try_from
provided byTryFrom
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
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);