readded local_language config option
This commit is contained in:
parent
c9fd2fea81
commit
84aa7c3278
@ -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
|
* `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
|
* `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
|
* `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)
|
||||||
|
@ -41,6 +41,8 @@ lazy_static! {
|
|||||||
.unwrap_or(60 * 60 * 24 * 365 * 50);
|
.unwrap_or(60 * 60 * 24 * 365 * 50);
|
||||||
pub static ref LOCAL_TIMEZONE: String =
|
pub static ref LOCAL_TIMEZONE: String =
|
||||||
env::var("LOCAL_TIMEZONE").unwrap_or_else(|_| "UTC".to_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 =
|
pub static ref PYTHON_LOCATION: String =
|
||||||
env::var("PYTHON_LOCATION").unwrap_or_else(|_| "venv/bin/python3".to_string());
|
env::var("PYTHON_LOCATION").unwrap_or_else(|_| "venv/bin/python3".to_string());
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use sqlx::MySqlPool;
|
|||||||
use chrono::NaiveDateTime;
|
use chrono::NaiveDateTime;
|
||||||
use chrono_tz::Tz;
|
use chrono_tz::Tz;
|
||||||
|
|
||||||
use crate::consts::PREFIX;
|
use crate::consts::{LOCAL_LANGUAGE, PREFIX};
|
||||||
|
|
||||||
pub struct GuildData {
|
pub struct GuildData {
|
||||||
pub id: u32,
|
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 {
|
pub async fn response(&self, pool: &MySqlPool, name: &str) -> String {
|
||||||
let row = sqlx::query!(
|
let row = sqlx::query!(
|
||||||
"
|
"
|
||||||
SELECT value FROM strings WHERE (language = ? OR language = 'EN') AND name = ? ORDER BY language = 'EN'
|
SELECT value FROM strings WHERE (language = ? OR language = ?) AND name = ? ORDER BY language = ?
|
||||||
", self.language, name)
|
", self.language, *LOCAL_LANGUAGE, name, *LOCAL_LANGUAGE)
|
||||||
.fetch_one(pool)
|
.fetch_one(pool)
|
||||||
.await
|
.await
|
||||||
.unwrap_or_else(|_| panic!("No string with that name: {}", name));
|
.unwrap_or_else(|_| panic!("No string with that name: {}", name));
|
||||||
|
Loading…
Reference in New Issue
Block a user