From 16825f006f465faa6b54ba3dc4bcfeb5934b6a8f Mon Sep 17 00:00:00 2001 From: Xyon Date: Tue, 8 Oct 2024 00:05:13 +0100 Subject: [PATCH 1/2] Complete string translation efforts from feature --- src/config.rs | 4 +--- src/lib.rs | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index c1d1c86..f32d657 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,5 +1,4 @@ use std::collections::HashMap; -use std::path::PathBuf; use config::Config; use poise::serenity_prelude::ChannelId; use crate::ManifoldResult; @@ -26,8 +25,7 @@ pub struct ManifoldConfig { pub nickname: String, pub services: HashMap, pub database: DatabaseConfig, - pub responses_file_path: PathBuf, - pub locale: String, + pub responses_file_path: String, } impl ManifoldConfig { diff --git a/src/lib.rs b/src/lib.rs index ef6c81a..38615e0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -81,8 +81,9 @@ pub async fn prepare_client(arguments: ArgMatches, intents: Gat info!("Reading configuration..."); debug!("Configuration file path: {}", &config_file); let bot_config = ManifoldConfig::new(&config_file, bot_environment).expect(&*format!("Could not read configuration file {}", &config_file)); + let bot_locale = arguments.get_one::("locale").unwrap(); - rust_i18n::set_locale(bot_config.locale.as_str()); + rust_i18n::set_locale(bot_locale); let manager = ConnectionManager::::new(format!("postgresql://{user}:{pass}@{host}:{port}/{database}", user=&bot_config.database.user, pass=&bot_config.database.pass, host=&bot_config.database.host, port=&bot_config.database.port, database=&bot_config.database.database_name)); let pool = r2d2::Pool::builder() @@ -91,7 +92,7 @@ pub async fn prepare_client(arguments: ArgMatches, intents: Gat .expect("Database setup error!"); let mut responses = Responses::new(); - responses.reload(&PathBuf::from(&bot_config.responses_file_path)).expect("Could not load responses file!"); + responses.reload(&PathBuf::from(&format!("{file}.{locale}.txt", file=bot_config.responses_file_path, locale=bot_locale))).expect("Could not load responses file!"); let token = env::var("DISCORD_TOKEN").expect( "Could not find an environment variable called DISCORD_TOKEN", -- 2.30.2 From 096234f4232e3afcba5dd20e53d417cdaa12cf54 Mon Sep 17 00:00:00 2001 From: Xyon Date: Tue, 8 Oct 2024 00:06:27 +0100 Subject: [PATCH 2/2] Bump manifold version --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 4347ec4..25f67a6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "manifold" -version = "6.0.0" +version = "6.1.0" authors = ["Lucy Bladen "] edition = "2021" -- 2.30.2