diff --git a/Cargo.toml b/Cargo.toml index efec271..e00c6f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,6 +17,7 @@ readme = "README.md" [dependencies] lazy_static = "1.4.0" regex = "1.3.4" +whatlang = "0.12.0" [features] default = ["search"] diff --git a/src/commands/query.rs b/src/commands/query.rs index 8823a7c..66b94f9 100644 --- a/src/commands/query.rs +++ b/src/commands/query.rs @@ -1,4 +1,5 @@ use super::StreamCommand; +use whatlang::{detect}; use crate::result::*; use regex::Regex; @@ -32,6 +33,13 @@ impl StreamCommand for QueryCommand<'_> { if let Some(offset) = self.offset.as_ref() { message.push_str(&format!(" OFFSET({})", offset)); } + + // use greyblake/whatlang-rs to autodect locale + let text = detect(self.terms).unwrap(); + if text.confidence() == 1.0 { + message.push_str(&format!(" LANG({})", text.lang().code())); + } + message.push_str("\r\n"); message }