translate default deck config name
This commit is contained in:
parent
d342955830
commit
dfa1ce6429
@ -1,7 +1,8 @@
|
|||||||
# Used in the deck configuration screen to show how many decks are used
|
# Used in the deck configuration screen to show how many decks are used
|
||||||
# by a particular configuration group, eg "Group1 (used by 3 decks)"
|
# by a particular configuration group, eg "Group1 (used by 3 decks)"
|
||||||
deck-config-used-by-decks = used by { $decks ->
|
deck-config-used-by-decks =
|
||||||
[one] 1 deck
|
used by { $decks ->
|
||||||
*[other] {$decks} decks
|
[one] 1 deck
|
||||||
}
|
*[other] { $decks } decks
|
||||||
|
}
|
||||||
|
deck-config-default-name = Default
|
||||||
|
@ -18,7 +18,7 @@ pub fn open_collection<P: Into<PathBuf>>(
|
|||||||
log: Logger,
|
log: Logger,
|
||||||
) -> Result<Collection> {
|
) -> Result<Collection> {
|
||||||
let col_path = path.into();
|
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 {
|
let col = Collection {
|
||||||
storage,
|
storage,
|
||||||
|
@ -115,12 +115,13 @@ impl super::SqliteStorage {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use crate::{card::Card, storage::SqliteStorage};
|
use crate::{card::Card, i18n::I18n, log, storage::SqliteStorage};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn add_card() {
|
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();
|
let mut card = Card::default();
|
||||||
storage.add_card(&mut card).unwrap();
|
storage.add_card(&mut card).unwrap();
|
||||||
let id1 = card.id;
|
let id1 = card.id;
|
||||||
|
@ -5,6 +5,7 @@ use super::SqliteStorage;
|
|||||||
use crate::{
|
use crate::{
|
||||||
deckconf::{DeckConf, DeckConfID},
|
deckconf::{DeckConf, DeckConfID},
|
||||||
err::Result,
|
err::Result,
|
||||||
|
i18n::{FString, I18n},
|
||||||
};
|
};
|
||||||
use rusqlite::{params, NO_PARAMS};
|
use rusqlite::{params, NO_PARAMS};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
@ -71,9 +72,10 @@ impl SqliteStorage {
|
|||||||
|
|
||||||
// Creating/upgrading/downgrading
|
// 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();
|
let mut conf = DeckConf::default();
|
||||||
conf.id.0 = 1;
|
conf.id.0 = 1;
|
||||||
|
conf.name = i18n.tr(FString::DeckConfigDefaultName).into();
|
||||||
self.add_deck_conf(&mut conf)
|
self.add_deck_conf(&mut conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ use crate::notetypes::NoteTypeID;
|
|||||||
use crate::timestamp::{TimestampMillis, TimestampSecs};
|
use crate::timestamp::{TimestampMillis, TimestampSecs};
|
||||||
use crate::{
|
use crate::{
|
||||||
decks::Deck,
|
decks::Deck,
|
||||||
|
i18n::I18n,
|
||||||
notetypes::NoteType,
|
notetypes::NoteType,
|
||||||
sched::cutoff::{sched_timing_today, SchedTimingToday},
|
sched::cutoff::{sched_timing_today, SchedTimingToday},
|
||||||
text::without_combining,
|
text::without_combining,
|
||||||
@ -156,7 +157,7 @@ fn trace(s: &str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl SqliteStorage {
|
impl SqliteStorage {
|
||||||
pub(crate) fn open_or_create(path: &Path) -> Result<Self> {
|
pub(crate) fn open_or_create(path: &Path, i18n: &I18n) -> Result<Self> {
|
||||||
let db = open_or_create_collection_db(path)?;
|
let db = open_or_create_collection_db(path)?;
|
||||||
let (create, ver) = schema_version(&db)?;
|
let (create, ver) = schema_version(&db)?;
|
||||||
if ver > SCHEMA_MAX_VERSION {
|
if ver > SCHEMA_MAX_VERSION {
|
||||||
@ -193,7 +194,7 @@ impl SqliteStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if create {
|
if create {
|
||||||
storage.add_default_deck_config()?;
|
storage.add_default_deck_config(i18n)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if create || upgrade {
|
if create || upgrade {
|
||||||
|
Loading…
Reference in New Issue
Block a user