From dfa1ce64296c84cc80bbee4a5d7ddf159921e428 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Wed, 1 Apr 2020 17:49:25 +1000 Subject: [PATCH] translate default deck config name --- rslib/ftl/deck-config.ftl | 11 ++++++----- rslib/src/collection.rs | 2 +- rslib/src/storage/card/mod.rs | 5 +++-- rslib/src/storage/deckconf/mod.rs | 4 +++- rslib/src/storage/sqlite.rs | 5 +++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/rslib/ftl/deck-config.ftl b/rslib/ftl/deck-config.ftl index 6bb471975..077e52b6b 100644 --- a/rslib/ftl/deck-config.ftl +++ b/rslib/ftl/deck-config.ftl @@ -1,7 +1,8 @@ # Used in the deck configuration screen to show how many decks are used # by a particular configuration group, eg "Group1 (used by 3 decks)" -deck-config-used-by-decks = used by { $decks -> - [one] 1 deck - *[other] {$decks} decks - } - +deck-config-used-by-decks = + used by { $decks -> + [one] 1 deck + *[other] { $decks } decks + } +deck-config-default-name = Default diff --git a/rslib/src/collection.rs b/rslib/src/collection.rs index e4b8ed937..8afee6bbc 100644 --- a/rslib/src/collection.rs +++ b/rslib/src/collection.rs @@ -18,7 +18,7 @@ pub fn open_collection>( log: Logger, ) -> Result { let col_path = path.into(); - let storage = SqliteStorage::open_or_create(&col_path)?; + let storage = SqliteStorage::open_or_create(&col_path, &i18n)?; let col = Collection { storage, diff --git a/rslib/src/storage/card/mod.rs b/rslib/src/storage/card/mod.rs index 89d45fcd0..3dbcdaab4 100644 --- a/rslib/src/storage/card/mod.rs +++ b/rslib/src/storage/card/mod.rs @@ -115,12 +115,13 @@ impl super::SqliteStorage { #[cfg(test)] mod test { - use crate::{card::Card, storage::SqliteStorage}; + use crate::{card::Card, i18n::I18n, log, storage::SqliteStorage}; use std::path::Path; #[test] fn add_card() { - let storage = SqliteStorage::open_or_create(Path::new(":memory:")).unwrap(); + let i18n = I18n::new(&[""], "", log::terminal()); + let storage = SqliteStorage::open_or_create(Path::new(":memory:"), &i18n).unwrap(); let mut card = Card::default(); storage.add_card(&mut card).unwrap(); let id1 = card.id; diff --git a/rslib/src/storage/deckconf/mod.rs b/rslib/src/storage/deckconf/mod.rs index 3dfeac594..4b3d25d1c 100644 --- a/rslib/src/storage/deckconf/mod.rs +++ b/rslib/src/storage/deckconf/mod.rs @@ -5,6 +5,7 @@ use super::SqliteStorage; use crate::{ deckconf::{DeckConf, DeckConfID}, err::Result, + i18n::{FString, I18n}, }; use rusqlite::{params, NO_PARAMS}; use std::collections::HashMap; @@ -71,9 +72,10 @@ impl SqliteStorage { // Creating/upgrading/downgrading - pub(super) fn add_default_deck_config(&self) -> Result<()> { + pub(super) fn add_default_deck_config(&self, i18n: &I18n) -> Result<()> { let mut conf = DeckConf::default(); conf.id.0 = 1; + conf.name = i18n.tr(FString::DeckConfigDefaultName).into(); self.add_deck_conf(&mut conf) } diff --git a/rslib/src/storage/sqlite.rs b/rslib/src/storage/sqlite.rs index ec4b4fc6d..2bd005bf6 100644 --- a/rslib/src/storage/sqlite.rs +++ b/rslib/src/storage/sqlite.rs @@ -9,6 +9,7 @@ use crate::notetypes::NoteTypeID; use crate::timestamp::{TimestampMillis, TimestampSecs}; use crate::{ decks::Deck, + i18n::I18n, notetypes::NoteType, sched::cutoff::{sched_timing_today, SchedTimingToday}, text::without_combining, @@ -156,7 +157,7 @@ fn trace(s: &str) { } impl SqliteStorage { - pub(crate) fn open_or_create(path: &Path) -> Result { + pub(crate) fn open_or_create(path: &Path, i18n: &I18n) -> Result { let db = open_or_create_collection_db(path)?; let (create, ver) = schema_version(&db)?; if ver > SCHEMA_MAX_VERSION { @@ -193,7 +194,7 @@ impl SqliteStorage { } if create { - storage.add_default_deck_config()?; + storage.add_default_deck_config(i18n)?; } if create || upgrade {