Made language delimiter in the translate plugin configurable
This commit is contained in:
@@ -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)
|
||||
|
@@ -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 `<prefix><target lang> <text to translate>` or `<prefix><src lang><language_delimiter><target lang> <text to translate>`,
|
||||
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
|
||||
// <Anyrun config dir>/translate.ron
|
||||
Config(
|
||||
prefix: ":",
|
||||
language_delimiter: ">",
|
||||
max_entries: 3,
|
||||
)
|
||||
```
|
@@ -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<Match> {
|
||||
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),
|
||||
};
|
||||
|
Reference in New Issue
Block a user