diff --git a/README.md b/README.md index 6a7d43a..4ca9926 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,8 @@ Anyrun requires plugins to function, as they provide the results for input. The - Calculator & unit conversion. - [Shell](plugins/shell/README.md) - Run shell commands. +- [Translate](plugins/translate/README.md) + - Quickly translate text. - [Kidex](plugins/kidex/README.md) - File search provided by [Kidex](https://github.com/Kirottu/kidex). - [Randr](plugins/randr/README.md) diff --git a/plugins/translate/README.md b/plugins/translate/README.md index 710b58e..55d79ef 100644 --- a/plugins/translate/README.md +++ b/plugins/translate/README.md @@ -4,7 +4,8 @@ Quickly translate text using the Google Translate API. ## Usage -Type in `[prefix][target lang] [text to translate]` or `[prefix][src lang]>[target lang] [text to translate]`, where prefix is the configured prefix (default is in [Configuration](#Configuration)) and the rest are pretty obvious. +Type in ` ` or ` `, +where the `prefix` and `language_delimiter` are config options (defaults are in [Configuration](#Configuration)) and the rest are pretty obvious. ## Configuration @@ -12,6 +13,7 @@ Type in `[prefix][target lang] [text to translate]` or `[prefix][src lang]>[targ // /translate.ron Config( prefix: ":", + language_delimiter: ">", max_entries: 3, ) ``` \ No newline at end of file diff --git a/plugins/translate/src/lib.rs b/plugins/translate/src/lib.rs index b1b7427..d4af44f 100644 --- a/plugins/translate/src/lib.rs +++ b/plugins/translate/src/lib.rs @@ -10,6 +10,7 @@ use tokio::runtime::Runtime; #[derive(Deserialize)] struct Config { prefix: String, + language_delimiter: String, max_entries: usize, } @@ -17,6 +18,7 @@ impl Default for Config { fn default() -> Self { Self { prefix: ":".to_string(), + language_delimiter: ">".to_string(), max_entries: 3, } } @@ -169,7 +171,7 @@ fn get_matches(input: RString, state: &State) -> RVec { None => return RVec::new(), }; - let (src, dest) = match lang_split.split_once('>') { + let (src, dest) = match lang_split.split_once(&state.config.language_delimiter) { Some(split) => (Some(split.0), split.1), None => (None, lang_split), };