use auto detect source language
parent
60d011a5db
commit
3c92b26599
|
@ -1,4 +1,5 @@
|
|||
.vscode/
|
||||
.idea
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -34,7 +34,7 @@ pub mod deepl_helper {
|
|||
let matches = App::from_yaml(yaml).get_matches();
|
||||
|
||||
Self {
|
||||
source_lang: matches.value_of("source").unwrap_or("DE").to_string(),
|
||||
source_lang: matches.value_of("source").unwrap_or("0").to_string(),
|
||||
target_lang: matches.value_of("target").unwrap_or("EN-US").to_string(),
|
||||
file: matches.value_of("file").unwrap_or_default().to_string(),
|
||||
key: env::var("key").unwrap(),
|
||||
|
@ -48,14 +48,20 @@ pub mod deepl_helper {
|
|||
}
|
||||
|
||||
pub fn body(&self) -> String {
|
||||
sprintf!(
|
||||
"auth_key=%s&text=%s&target_lang=%s&source_lang=%s",
|
||||
let mut body = sprintf!(
|
||||
"auth_key=%s&text=%s&target_lang=%s",
|
||||
self.key,
|
||||
self.text,
|
||||
self.target_lang,
|
||||
self.source_lang
|
||||
self.target_lang
|
||||
)
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
|
||||
if self.source_lang != "0" {
|
||||
let add = sprintf!("&source_lang=%s", self.source_lang).unwrap();
|
||||
body.push_str(&add);
|
||||
}
|
||||
|
||||
body
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue