fixes for locales, improvements, more logging, stub cs translation

This commit is contained in:
2021-10-10 15:38:56 +02:00
parent 239e15afdd
commit e76da157b3
11 changed files with 130 additions and 70 deletions
+14
View File
@@ -1,9 +1,12 @@
use std::collections::HashMap;
use crate::store::DEFAULT_LOCALE_NAME;
use crate::tr::TranslationTable;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(default, deny_unknown_fields)]
pub struct CommonConfig {
pub groups_dir: String,
pub locales_dir: String,
/// Max number of missed notifs to process after connect
pub max_catchup_notifs: usize,
/// Max number of missed statuses to process after connect
@@ -31,6 +34,8 @@ pub struct CommonConfig {
impl Default for CommonConfig {
fn default() -> Self {
Self {
groups_dir: "groups".to_string(),
locales_dir: "locales".to_string(),
max_catchup_notifs: 30,
max_catchup_statuses: 50,
delay_fetch_page_s: 0.25,
@@ -43,3 +48,12 @@ impl Default for CommonConfig {
}
}
}
impl CommonConfig {
pub fn tr(&self, lang : &str) -> &TranslationTable {
match self.tr.get(lang) {
Some(tr) => tr,
None => self.tr.get(DEFAULT_LOCALE_NAME).expect("default locale is not loaded")
}
}
}