use auto detect source language
This commit is contained in:
+12
-6
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user