readded local_language config option

This commit is contained in:
jude 2020-10-12 22:43:02 +01:00
parent c9fd2fea81
commit 84aa7c3278
3 changed files with 6 additions and 3 deletions

View File

@ -31,3 +31,4 @@ __Other Variables__
* `CNC_GUILD` - default `None`, accepts a single Discord guild ID for the server that the subscription roles belong to
* `IGNORE_BOTS` - default `1`, if `1`, Reminder Bot will ignore all other bots
* `PYTHON_LOCATION` - default `venv/bin/python3`. Can be changed if your Python executable is located somewhere else
* `LOCAL_LANGUAGE` - default `EN`. Specifies the string set to fall back to if a string cannot be found (and to be used with new users)

View File

@ -41,6 +41,8 @@ lazy_static! {
.unwrap_or(60 * 60 * 24 * 365 * 50);
pub static ref LOCAL_TIMEZONE: String =
env::var("LOCAL_TIMEZONE").unwrap_or_else(|_| "UTC".to_string());
pub static ref LOCAL_LANGUAGE: String =
env::var("LOCAL_LANGUAGE").unwrap_or_else(|_| "EN".to_string());
pub static ref PYTHON_LOCATION: String =
env::var("PYTHON_LOCATION").unwrap_or_else(|_| "venv/bin/python3".to_string());
}

View File

@ -10,7 +10,7 @@ use sqlx::MySqlPool;
use chrono::NaiveDateTime;
use chrono_tz::Tz;
use crate::consts::PREFIX;
use crate::consts::{LOCAL_LANGUAGE, PREFIX};
pub struct GuildData {
pub id: u32,
@ -251,8 +251,8 @@ UPDATE users SET name = ?, language = ?, timezone = ? WHERE id = ?
pub async fn response(&self, pool: &MySqlPool, name: &str) -> String {
let row = sqlx::query!(
"
SELECT value FROM strings WHERE (language = ? OR language = 'EN') AND name = ? ORDER BY language = 'EN'
", self.language, name)
SELECT value FROM strings WHERE (language = ? OR language = ?) AND name = ? ORDER BY language = ?
", self.language, *LOCAL_LANGUAGE, name, *LOCAL_LANGUAGE)
.fetch_one(pool)
.await
.unwrap_or_else(|_| panic!("No string with that name: {}", name));