update no-arg TR references in rslib/
This commit is contained in:
parent
5abc48932c
commit
dc5fdd30d4
@ -9,13 +9,13 @@ from re import Match
|
||||
|
||||
import stringcase
|
||||
|
||||
TR_REF = re.compile(r"i18n\.tr\(i18n\.TR\.([^,) ]+)\)")
|
||||
TR_REF = re.compile(r"\.tr\(\s*TR::([^,) ]+)\)")
|
||||
|
||||
|
||||
def repl(m: Match) -> str:
|
||||
name = stringcase.camelcase(m.group(1).lower())
|
||||
name = stringcase.snakecase(m.group(1))
|
||||
# args = m.group(2)
|
||||
return f"i18n.{name}()"
|
||||
return f".{name}()"
|
||||
|
||||
|
||||
def update_py(path: str) -> None:
|
||||
@ -31,5 +31,5 @@ for dirpath, dirnames, fnames in os.walk(os.environ["BUILD_WORKSPACE_DIRECTORY"]
|
||||
if "bazel-" in dirpath:
|
||||
continue
|
||||
for fname in fnames:
|
||||
if fname.endswith(".svelte"):
|
||||
if fname.endswith(".rs"):
|
||||
update_py(os.path.join(dirpath, fname))
|
||||
|
@ -66,9 +66,9 @@ pub(super) fn progress_to_proto(progress: Option<Progress>, i18n: &I18n) -> pb::
|
||||
}),
|
||||
Progress::NormalSync(p) => {
|
||||
let stage = match p.stage {
|
||||
SyncStage::Connecting => i18n.tr(TR::SyncSyncing),
|
||||
SyncStage::Syncing => i18n.tr(TR::SyncSyncing),
|
||||
SyncStage::Finalizing => i18n.tr(TR::SyncChecking),
|
||||
SyncStage::Connecting => i18n.sync_syncing(),
|
||||
SyncStage::Syncing => i18n.sync_syncing(),
|
||||
SyncStage::Finalizing => i18n.sync_checking(),
|
||||
}
|
||||
.to_string();
|
||||
let added = i18n.trn(
|
||||
@ -91,15 +91,15 @@ pub(super) fn progress_to_proto(progress: Option<Progress>, i18n: &I18n) -> pb::
|
||||
let mut stage_total = 0;
|
||||
let mut stage_current = 0;
|
||||
let stage = match p {
|
||||
DatabaseCheckProgress::Integrity => i18n.tr(TR::DatabaseCheckCheckingIntegrity),
|
||||
DatabaseCheckProgress::Optimize => i18n.tr(TR::DatabaseCheckRebuilding),
|
||||
DatabaseCheckProgress::Cards => i18n.tr(TR::DatabaseCheckCheckingCards),
|
||||
DatabaseCheckProgress::Integrity => i18n.database_check_checking_integrity(),
|
||||
DatabaseCheckProgress::Optimize => i18n.database_check_rebuilding(),
|
||||
DatabaseCheckProgress::Cards => i18n.database_check_checking_cards(),
|
||||
DatabaseCheckProgress::Notes { current, total } => {
|
||||
stage_total = total;
|
||||
stage_current = current;
|
||||
i18n.tr(TR::DatabaseCheckCheckingNotes)
|
||||
i18n.database_check_checking_notes()
|
||||
}
|
||||
DatabaseCheckProgress::History => i18n.tr(TR::DatabaseCheckCheckingHistory),
|
||||
DatabaseCheckProgress::History => i18n.database_check_checking_history(),
|
||||
}
|
||||
.to_string();
|
||||
pb::progress::Value::DatabaseCheck(pb::progress::DatabaseCheck {
|
||||
|
@ -236,7 +236,7 @@ impl<'a> RowContext<'a> {
|
||||
|
||||
fn card_due_str(&mut self) -> String {
|
||||
let due = if self.card.original_deck_id != DeckID(0) {
|
||||
self.i18n.tr(TR::BrowsingFiltered).into()
|
||||
self.i18n.browsing_filtered().into()
|
||||
} else if self.card.queue == CardQueue::New || self.card.ctype == CardType::New {
|
||||
self.i18n.trn(
|
||||
TR::StatisticsDueForNewCard,
|
||||
@ -265,15 +265,15 @@ impl<'a> RowContext<'a> {
|
||||
|
||||
fn card_ease_str(&self) -> String {
|
||||
match self.card.ctype {
|
||||
CardType::New => self.i18n.tr(TR::BrowsingNew).into(),
|
||||
CardType::New => self.i18n.browsing_new().into(),
|
||||
_ => format!("{}%", self.card.ease_factor / 10),
|
||||
}
|
||||
}
|
||||
|
||||
fn card_interval_str(&self) -> String {
|
||||
match self.card.ctype {
|
||||
CardType::New => self.i18n.tr(TR::BrowsingNew).into(),
|
||||
CardType::Learn => self.i18n.tr(TR::BrowsingLearning).into(),
|
||||
CardType::New => self.i18n.browsing_new().into(),
|
||||
CardType::Learn => self.i18n.browsing_learning().into(),
|
||||
_ => time_span((self.card.interval * 86400) as f32, self.i18n, false),
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ impl Collection {
|
||||
if self.storage.quick_check_corrupt() {
|
||||
debug!(self.log, "quick check failed");
|
||||
return Err(AnkiError::DBError {
|
||||
info: self.i18n.tr(TR::DatabaseCheckCorrupt).into(),
|
||||
info: self.i18n.database_check_corrupt().into(),
|
||||
kind: DBErrorKind::Corrupt,
|
||||
});
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ use crate::{
|
||||
deckconf::DeckConfID,
|
||||
define_newtype,
|
||||
err::{AnkiError, Result},
|
||||
i18n::TR,
|
||||
prelude::*,
|
||||
text::normalize_to_nfc,
|
||||
timestamp::TimestampSecs,
|
||||
@ -513,7 +512,7 @@ impl Collection {
|
||||
if deck.id.0 == 1 {
|
||||
// if deleting the default deck, ensure there's a new one, and avoid the grave
|
||||
let mut deck = deck.to_owned();
|
||||
deck.name = self.i18n.tr(TR::DeckConfigDefaultName).into();
|
||||
deck.name = self.i18n.deck_config_default_name().into();
|
||||
deck.set_modified(usn);
|
||||
self.add_or_update_single_deck_with_existing_id(&mut deck, usn)?;
|
||||
} else {
|
||||
|
@ -95,23 +95,23 @@ impl AnkiError {
|
||||
AnkiError::SyncError { info, kind } => match kind {
|
||||
SyncErrorKind::ServerMessage => info.into(),
|
||||
SyncErrorKind::Other => info.into(),
|
||||
SyncErrorKind::Conflict => i18n.tr(TR::SyncConflict),
|
||||
SyncErrorKind::ServerError => i18n.tr(TR::SyncServerError),
|
||||
SyncErrorKind::ClientTooOld => i18n.tr(TR::SyncClientTooOld),
|
||||
SyncErrorKind::AuthFailed => i18n.tr(TR::SyncWrongPass),
|
||||
SyncErrorKind::ResyncRequired => i18n.tr(TR::SyncResyncRequired),
|
||||
SyncErrorKind::ClockIncorrect => i18n.tr(TR::SyncClockOff),
|
||||
SyncErrorKind::DatabaseCheckRequired => i18n.tr(TR::SyncSanityCheckFailed),
|
||||
SyncErrorKind::Conflict => i18n.sync_conflict(),
|
||||
SyncErrorKind::ServerError => i18n.sync_server_error(),
|
||||
SyncErrorKind::ClientTooOld => i18n.sync_client_too_old(),
|
||||
SyncErrorKind::AuthFailed => i18n.sync_wrong_pass(),
|
||||
SyncErrorKind::ResyncRequired => i18n.sync_resync_required(),
|
||||
SyncErrorKind::ClockIncorrect => i18n.sync_clock_off(),
|
||||
SyncErrorKind::DatabaseCheckRequired => i18n.sync_sanity_check_failed(),
|
||||
// server message
|
||||
SyncErrorKind::SyncNotStarted => "sync not started".into(),
|
||||
}
|
||||
.into(),
|
||||
AnkiError::NetworkError { kind, info } => {
|
||||
let summary = match kind {
|
||||
NetworkErrorKind::Offline => i18n.tr(TR::NetworkOffline),
|
||||
NetworkErrorKind::Timeout => i18n.tr(TR::NetworkTimeout),
|
||||
NetworkErrorKind::ProxyAuth => i18n.tr(TR::NetworkProxyAuth),
|
||||
NetworkErrorKind::Other => i18n.tr(TR::NetworkOther),
|
||||
NetworkErrorKind::Offline => i18n.network_offline(),
|
||||
NetworkErrorKind::Timeout => i18n.network_timeout(),
|
||||
NetworkErrorKind::ProxyAuth => i18n.network_proxy_auth(),
|
||||
NetworkErrorKind::Other => i18n.network_other(),
|
||||
};
|
||||
let details = i18n.trn(TR::NetworkDetails, tr_strs!["details"=>info]);
|
||||
format!("{}\n\n{}", summary, details)
|
||||
@ -131,14 +131,14 @@ impl AnkiError {
|
||||
},
|
||||
AnkiError::SearchError(kind) => {
|
||||
let reason = match kind {
|
||||
SearchErrorKind::MisplacedAnd => i18n.tr(TR::SearchMisplacedAnd),
|
||||
SearchErrorKind::MisplacedOr => i18n.tr(TR::SearchMisplacedOr),
|
||||
SearchErrorKind::EmptyGroup => i18n.tr(TR::SearchEmptyGroup),
|
||||
SearchErrorKind::UnopenedGroup => i18n.tr(TR::SearchUnopenedGroup),
|
||||
SearchErrorKind::UnclosedGroup => i18n.tr(TR::SearchUnclosedGroup),
|
||||
SearchErrorKind::EmptyQuote => i18n.tr(TR::SearchEmptyQuote),
|
||||
SearchErrorKind::UnclosedQuote => i18n.tr(TR::SearchUnclosedQuote),
|
||||
SearchErrorKind::MissingKey => i18n.tr(TR::SearchMissingKey),
|
||||
SearchErrorKind::MisplacedAnd => i18n.search_misplaced_and(),
|
||||
SearchErrorKind::MisplacedOr => i18n.search_misplaced_or(),
|
||||
SearchErrorKind::EmptyGroup => i18n.search_empty_group(),
|
||||
SearchErrorKind::UnopenedGroup => i18n.search_unopened_group(),
|
||||
SearchErrorKind::UnclosedGroup => i18n.search_unclosed_group(),
|
||||
SearchErrorKind::EmptyQuote => i18n.search_empty_quote(),
|
||||
SearchErrorKind::UnclosedQuote => i18n.search_unclosed_quote(),
|
||||
SearchErrorKind::MissingKey => i18n.search_missing_key(),
|
||||
SearchErrorKind::UnknownEscape(ctx) => i18n
|
||||
.trn(
|
||||
TR::SearchUnknownEscape,
|
||||
@ -151,7 +151,7 @@ impl AnkiError {
|
||||
tr_strs!("term" => "is:", "argument" => state.replace('`', "'")),
|
||||
)
|
||||
.into(),
|
||||
SearchErrorKind::InvalidFlag => i18n.tr(TR::SearchInvalidFlag),
|
||||
SearchErrorKind::InvalidFlag => i18n.search_invalid_flag(),
|
||||
SearchErrorKind::InvalidPropProperty(prop) => i18n
|
||||
.trn(
|
||||
TR::SearchInvalidArgument,
|
||||
@ -163,7 +163,7 @@ impl AnkiError {
|
||||
.into(),
|
||||
SearchErrorKind::Regex(text) => format!("<pre>`{}`</pre>", text.replace('`', "'")).into(),
|
||||
SearchErrorKind::Other(Some(info)) => info.into(),
|
||||
SearchErrorKind::Other(None) => i18n.tr(TR::SearchInvalidOther),
|
||||
SearchErrorKind::Other(None) => i18n.search_invalid_other(),
|
||||
SearchErrorKind::InvalidNumber { provided, context } => i18n
|
||||
.trn(
|
||||
TR::SearchInvalidNumber,
|
||||
@ -202,7 +202,7 @@ impl AnkiError {
|
||||
}
|
||||
AnkiError::InvalidInput { info } => {
|
||||
if info.is_empty() {
|
||||
i18n.tr(TR::ErrorsInvalidInputEmpty).into()
|
||||
i18n.errors_invalid_input_empty().into()
|
||||
} else {
|
||||
i18n.trn(
|
||||
TR::ErrorsInvalidInputDetails,
|
||||
@ -210,9 +210,9 @@ impl AnkiError {
|
||||
)
|
||||
}
|
||||
}
|
||||
AnkiError::ParseNumError => i18n.tr(TR::ErrorsParseNumberFail).into(),
|
||||
AnkiError::DeckIsFiltered => i18n.tr(TR::ErrorsFilteredParentDeck).into(),
|
||||
AnkiError::FilteredDeckEmpty => i18n.tr(TR::DecksFilteredDeckSearchEmpty).into(),
|
||||
AnkiError::ParseNumError => i18n.errors_parse_number_fail().into(),
|
||||
AnkiError::DeckIsFiltered => i18n.errors_filtered_parent_deck().into(),
|
||||
AnkiError::FilteredDeckEmpty => i18n.decks_filtered_deck_search_empty().into(),
|
||||
_ => format!("{:?}", self),
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ where
|
||||
buf.push('\n');
|
||||
|
||||
if !output.renamed.is_empty() {
|
||||
buf += &i.tr(TR::MediaCheckRenamedHeader);
|
||||
buf += &i.media_check_renamed_header();
|
||||
buf.push('\n');
|
||||
for (old, new) in &output.renamed {
|
||||
buf += &i.trn(TR::MediaCheckRenamedFile, tr_strs!["old"=>old,"new"=>new]);
|
||||
@ -150,7 +150,7 @@ where
|
||||
|
||||
if !output.oversize.is_empty() {
|
||||
output.oversize.sort();
|
||||
buf += &i.tr(TR::MediaCheckOversizeHeader);
|
||||
buf += &i.media_check_oversize_header();
|
||||
buf.push('\n');
|
||||
for fname in &output.oversize {
|
||||
buf += &i.trn(TR::MediaCheckOversizeFile, tr_strs!["filename"=>fname]);
|
||||
@ -161,7 +161,7 @@ where
|
||||
|
||||
if !output.dirs.is_empty() {
|
||||
output.dirs.sort();
|
||||
buf += &i.tr(TR::MediaCheckSubfolderHeader);
|
||||
buf += &i.media_check_subfolder_header();
|
||||
buf.push('\n');
|
||||
for fname in &output.dirs {
|
||||
buf += &i.trn(TR::MediaCheckSubfolderFile, tr_strs!["filename"=>fname]);
|
||||
@ -172,7 +172,7 @@ where
|
||||
|
||||
if !output.missing.is_empty() {
|
||||
output.missing.sort();
|
||||
buf += &i.tr(TR::MediaCheckMissingHeader);
|
||||
buf += &i.media_check_missing_header();
|
||||
buf.push('\n');
|
||||
for fname in &output.missing {
|
||||
buf += &i.trn(TR::MediaCheckMissingFile, tr_strs!["filename"=>fname]);
|
||||
@ -183,7 +183,7 @@ where
|
||||
|
||||
if !output.unused.is_empty() {
|
||||
output.unused.sort();
|
||||
buf += &i.tr(TR::MediaCheckUnusedHeader);
|
||||
buf += &i.media_check_unused_header();
|
||||
buf.push('\n');
|
||||
for fname in &output.unused {
|
||||
buf += &i.trn(TR::MediaCheckUnusedFile, tr_strs!["filename"=>fname]);
|
||||
|
@ -104,7 +104,7 @@ impl Collection {
|
||||
// "Cloze 1, 3"
|
||||
NoteTypeKind::Cloze => format!(
|
||||
"{} {}",
|
||||
self.i18n.tr(TR::NotetypesClozeName),
|
||||
self.i18n.notetypes_cloze_name(),
|
||||
note.empty
|
||||
.iter()
|
||||
.map(|(ord, _)| (ord + 1).to_string())
|
||||
|
@ -6,7 +6,7 @@ use crate::{
|
||||
card::{Card, CardID},
|
||||
collection::Collection,
|
||||
err::{AnkiError, Result},
|
||||
i18n::{I18n, TR},
|
||||
i18n::I18n,
|
||||
notes::{Note, NoteID},
|
||||
template::{field_is_empty, render_card, ParsedTemplate, RenderedNode},
|
||||
};
|
||||
@ -172,7 +172,7 @@ fn fill_empty_fields(note: &mut Note, qfmt: &str, nt: &NoteType, i18n: &I18n) {
|
||||
for (val, field) in note.fields_mut().iter_mut().zip(nt.fields.iter()) {
|
||||
if field_is_empty(val) {
|
||||
if cloze_fields.contains(&field.name.as_str()) {
|
||||
*val = i18n.tr(TR::CardTemplatesSampleCloze).into();
|
||||
*val = i18n.card_templates_sample_cloze().into();
|
||||
} else {
|
||||
*val = format!("({})", field.name);
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ use crate::{
|
||||
config::{ConfigEntry, ConfigKey},
|
||||
err::Result,
|
||||
i18n::I18n,
|
||||
i18n::TR,
|
||||
notetype::NoteType,
|
||||
storage::SqliteStorage,
|
||||
timestamp::TimestampSecs,
|
||||
@ -49,15 +48,15 @@ fn fieldref<S: AsRef<str>>(name: S) -> String {
|
||||
|
||||
pub(crate) fn basic(i18n: &I18n) -> NoteType {
|
||||
let mut nt = NoteType {
|
||||
name: i18n.tr(TR::NotetypesBasicName).into(),
|
||||
name: i18n.notetypes_basic_name().into(),
|
||||
..Default::default()
|
||||
};
|
||||
let front = i18n.tr(TR::NotetypesFrontField);
|
||||
let back = i18n.tr(TR::NotetypesBackField);
|
||||
let front = i18n.notetypes_front_field();
|
||||
let back = i18n.notetypes_back_field();
|
||||
nt.add_field(front.as_ref());
|
||||
nt.add_field(back.as_ref());
|
||||
nt.add_template(
|
||||
i18n.tr(TR::NotetypesCard1Name),
|
||||
i18n.notetypes_card_1_name(),
|
||||
fieldref(front),
|
||||
format!(
|
||||
"{}\n\n<hr id=answer>\n\n{}",
|
||||
@ -71,9 +70,9 @@ pub(crate) fn basic(i18n: &I18n) -> NoteType {
|
||||
|
||||
pub(crate) fn basic_typing(i18n: &I18n) -> NoteType {
|
||||
let mut nt = basic(i18n);
|
||||
nt.name = i18n.tr(TR::NotetypesBasicTypeAnswerName).into();
|
||||
let front = i18n.tr(TR::NotetypesFrontField);
|
||||
let back = i18n.tr(TR::NotetypesBackField);
|
||||
nt.name = i18n.notetypes_basic_type_answer_name().into();
|
||||
let front = i18n.notetypes_front_field();
|
||||
let back = i18n.notetypes_back_field();
|
||||
let tmpl = &mut nt.templates[0].config;
|
||||
tmpl.q_format = format!("{}\n\n{{{{type:{}}}}}", fieldref(front.as_ref()), back);
|
||||
tmpl.a_format = format!(
|
||||
@ -87,11 +86,11 @@ pub(crate) fn basic_typing(i18n: &I18n) -> NoteType {
|
||||
|
||||
pub(crate) fn basic_forward_reverse(i18n: &I18n) -> NoteType {
|
||||
let mut nt = basic(i18n);
|
||||
nt.name = i18n.tr(TR::NotetypesBasicReversedName).into();
|
||||
let front = i18n.tr(TR::NotetypesFrontField);
|
||||
let back = i18n.tr(TR::NotetypesBackField);
|
||||
nt.name = i18n.notetypes_basic_reversed_name().into();
|
||||
let front = i18n.notetypes_front_field();
|
||||
let back = i18n.notetypes_back_field();
|
||||
nt.add_template(
|
||||
i18n.tr(TR::NotetypesCard2Name),
|
||||
i18n.notetypes_card_2_name(),
|
||||
fieldref(back),
|
||||
format!(
|
||||
"{}\n\n<hr id=answer>\n\n{}",
|
||||
@ -105,8 +104,8 @@ pub(crate) fn basic_forward_reverse(i18n: &I18n) -> NoteType {
|
||||
|
||||
pub(crate) fn basic_optional_reverse(i18n: &I18n) -> NoteType {
|
||||
let mut nt = basic_forward_reverse(i18n);
|
||||
nt.name = i18n.tr(TR::NotetypesBasicOptionalReversedName).into();
|
||||
let addrev = i18n.tr(TR::NotetypesAddReverseField);
|
||||
nt.name = i18n.notetypes_basic_optional_reversed_name().into();
|
||||
let addrev = i18n.notetypes_add_reverse_field();
|
||||
nt.add_field(addrev.as_ref());
|
||||
let tmpl = &mut nt.templates[1].config;
|
||||
tmpl.q_format = format!("{{{{#{}}}}}{}{{{{/{}}}}}", addrev, tmpl.q_format, addrev);
|
||||
@ -116,12 +115,12 @@ pub(crate) fn basic_optional_reverse(i18n: &I18n) -> NoteType {
|
||||
|
||||
pub(crate) fn cloze(i18n: &I18n) -> NoteType {
|
||||
let mut nt = NoteType {
|
||||
name: i18n.tr(TR::NotetypesClozeName).into(),
|
||||
name: i18n.notetypes_cloze_name().into(),
|
||||
..Default::default()
|
||||
};
|
||||
let text = i18n.tr(TR::NotetypesTextField);
|
||||
let text = i18n.notetypes_text_field();
|
||||
nt.add_field(text.as_ref());
|
||||
let back_extra = i18n.tr(TR::NotetypesBackExtraField);
|
||||
let back_extra = i18n.notetypes_back_extra_field();
|
||||
nt.add_field(back_extra.as_ref());
|
||||
let qfmt = format!("{{{{cloze:{}}}}}", text);
|
||||
let afmt = format!("{}<br>\n{{{{{}}}}}", qfmt, back_extra);
|
||||
|
@ -23,7 +23,7 @@ pub fn answer_button_time(seconds: f32, i18n: &I18n) -> String {
|
||||
pub fn answer_button_time_collapsible(seconds: u32, collapse_secs: u32, i18n: &I18n) -> String {
|
||||
let string = answer_button_time(seconds as f32, i18n);
|
||||
if seconds == 0 {
|
||||
i18n.tr(TR::SchedulingEnd).into()
|
||||
i18n.scheduling_end().into()
|
||||
} else if seconds < collapse_secs {
|
||||
format!("<{}", string)
|
||||
} else {
|
||||
|
@ -131,66 +131,54 @@ impl Collection {
|
||||
|
||||
let mut stats = vec![(i18n.card_stats_added().into(), cs.added.date_string())];
|
||||
if let Some(first) = cs.first_review {
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsFirstReview).into(),
|
||||
first.date_string(),
|
||||
))
|
||||
stats.push((i18n.card_stats_first_review().into(), first.date_string()))
|
||||
}
|
||||
if let Some(last) = cs.latest_review {
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsLatestReview).into(),
|
||||
last.date_string(),
|
||||
))
|
||||
stats.push((i18n.card_stats_latest_review().into(), last.date_string()))
|
||||
}
|
||||
|
||||
match cs.due {
|
||||
Due::Time(secs) => {
|
||||
stats.push((i18n.tr(TR::StatisticsDueDate).into(), secs.date_string()));
|
||||
stats.push((i18n.statistics_due_date().into(), secs.date_string()));
|
||||
}
|
||||
Due::Position(pos) => {
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsNewCardPosition).into(),
|
||||
pos.to_string(),
|
||||
));
|
||||
stats.push((i18n.card_stats_new_card_position().into(), pos.to_string()));
|
||||
}
|
||||
Due::Unknown => {}
|
||||
};
|
||||
|
||||
if cs.interval_secs > 0 {
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsInterval).into(),
|
||||
i18n.card_stats_interval().into(),
|
||||
time_span(cs.interval_secs as f32, i18n, true),
|
||||
));
|
||||
}
|
||||
|
||||
if cs.ease > 0 {
|
||||
stats.push((i18n.tr(TR::CardStatsEase).into(), format!("{}%", cs.ease)));
|
||||
stats.push((i18n.card_stats_ease().into(), format!("{}%", cs.ease)));
|
||||
}
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsReviewCount).into(),
|
||||
i18n.card_stats_review_count().into(),
|
||||
cs.reviews.to_string(),
|
||||
));
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsLapseCount).into(),
|
||||
cs.lapses.to_string(),
|
||||
));
|
||||
stats.push((i18n.card_stats_lapse_count().into(), cs.lapses.to_string()));
|
||||
|
||||
if cs.total_secs > 0.0 {
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsAverageTime).into(),
|
||||
i18n.card_stats_average_time().into(),
|
||||
time_span(cs.average_secs, i18n, true),
|
||||
));
|
||||
stats.push((
|
||||
i18n.tr(TR::CardStatsTotalTime).into(),
|
||||
i18n.card_stats_total_time().into(),
|
||||
time_span(cs.total_secs, i18n, true),
|
||||
));
|
||||
}
|
||||
|
||||
stats.push((i18n.tr(TR::CardStatsCardTemplate).into(), cs.card_type));
|
||||
stats.push((i18n.tr(TR::CardStatsNoteType).into(), cs.note_type));
|
||||
stats.push((i18n.tr(TR::CardStatsDeckName).into(), cs.deck));
|
||||
stats.push((i18n.tr(TR::CardStatsCardId).into(), cs.cid.0.to_string()));
|
||||
stats.push((i18n.tr(TR::CardStatsNoteId).into(), cs.nid.0.to_string()));
|
||||
stats.push((i18n.card_stats_card_template().into(), cs.card_type));
|
||||
stats.push((i18n.card_stats_note_type().into(), cs.note_type));
|
||||
stats.push((i18n.card_stats_deck_name().into(), cs.deck));
|
||||
stats.push((i18n.card_stats_card_id().into(), cs.cid.0.to_string()));
|
||||
stats.push((i18n.card_stats_note_id().into(), cs.nid.0.to_string()));
|
||||
|
||||
let revlog = cs
|
||||
.revlog
|
||||
@ -199,14 +187,14 @@ impl Collection {
|
||||
.map(|e| revlog_to_text(e, i18n))
|
||||
.collect();
|
||||
let revlog_titles = RevlogText {
|
||||
time: i18n.tr(TR::CardStatsReviewLogDate).into(),
|
||||
kind: i18n.tr(TR::CardStatsReviewLogType).into(),
|
||||
time: i18n.card_stats_review_log_date().into(),
|
||||
kind: i18n.card_stats_review_log_type().into(),
|
||||
kind_class: "".to_string(),
|
||||
rating: i18n.tr(TR::CardStatsReviewLogRating).into(),
|
||||
interval: i18n.tr(TR::CardStatsInterval).into(),
|
||||
ease: i18n.tr(TR::CardStatsEase).into(),
|
||||
rating: i18n.card_stats_review_log_rating().into(),
|
||||
interval: i18n.card_stats_interval().into(),
|
||||
ease: i18n.card_stats_ease().into(),
|
||||
rating_class: "".to_string(),
|
||||
taken_secs: i18n.tr(TR::CardStatsReviewLogTimeTaken).into(),
|
||||
taken_secs: i18n.card_stats_review_log_time_taken().into(),
|
||||
};
|
||||
|
||||
Ok(CardStatsTemplate {
|
||||
@ -223,11 +211,11 @@ fn revlog_to_text(e: RevlogEntry, i18n: &I18n) -> RevlogText {
|
||||
let dt = Local.timestamp(e.id.as_secs().0, 0);
|
||||
let time = dt.format("<b>%Y-%m-%d</b> @ %H:%M").to_string();
|
||||
let kind = match e.review_kind {
|
||||
RevlogReviewKind::Learning => i18n.tr(TR::CardStatsReviewLogTypeLearn).into(),
|
||||
RevlogReviewKind::Review => i18n.tr(TR::CardStatsReviewLogTypeReview).into(),
|
||||
RevlogReviewKind::Relearning => i18n.tr(TR::CardStatsReviewLogTypeRelearn).into(),
|
||||
RevlogReviewKind::EarlyReview => i18n.tr(TR::CardStatsReviewLogTypeFiltered).into(),
|
||||
RevlogReviewKind::Manual => i18n.tr(TR::CardStatsReviewLogTypeManual).into(),
|
||||
RevlogReviewKind::Learning => i18n.card_stats_review_log_type_learn().into(),
|
||||
RevlogReviewKind::Review => i18n.card_stats_review_log_type_review().into(),
|
||||
RevlogReviewKind::Relearning => i18n.card_stats_review_log_type_relearn().into(),
|
||||
RevlogReviewKind::EarlyReview => i18n.card_stats_review_log_type_filtered().into(),
|
||||
RevlogReviewKind::Manual => i18n.card_stats_review_log_type_manual().into(),
|
||||
};
|
||||
let kind_class = match e.review_kind {
|
||||
RevlogReviewKind::Learning => String::from("revlog-learn"),
|
||||
|
@ -9,7 +9,7 @@ use crate::{
|
||||
decks::immediate_parent_name,
|
||||
decks::{Deck, DeckCommon, DeckID, DeckKindProto, DeckSchema11, DueCounts},
|
||||
err::{AnkiError, DBErrorKind, Result},
|
||||
i18n::{I18n, TR},
|
||||
i18n::I18n,
|
||||
timestamp::TimestampMillis,
|
||||
};
|
||||
use prost::Message;
|
||||
@ -339,7 +339,7 @@ impl SqliteStorage {
|
||||
let mut deck = Deck::new_normal();
|
||||
deck.id.0 = 1;
|
||||
// fixme: separate key
|
||||
deck.name = i18n.tr(TR::DeckConfigDefaultName).into();
|
||||
deck.name = i18n.deck_config_default_name().into();
|
||||
self.add_or_update_deck_with_existing_id(&deck)
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ use super::SqliteStorage;
|
||||
use crate::{
|
||||
deckconf::{DeckConf, DeckConfID, DeckConfSchema11, DeckConfigInner},
|
||||
err::Result,
|
||||
i18n::{I18n, TR},
|
||||
i18n::I18n,
|
||||
};
|
||||
use prost::Message;
|
||||
use rusqlite::{params, Row, NO_PARAMS};
|
||||
@ -116,7 +116,7 @@ impl SqliteStorage {
|
||||
pub(super) fn add_default_deck_config(&self, i18n: &I18n) -> Result<()> {
|
||||
let mut conf = DeckConf::default();
|
||||
conf.id.0 = 1;
|
||||
conf.name = i18n.tr(TR::DeckConfigDefaultName).into();
|
||||
conf.name = i18n.deck_config_default_name().into();
|
||||
self.add_deck_conf(&mut conf)
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ fn template_error_to_anki_error(err: TemplateError, q_side: bool, i18n: &I18n) -
|
||||
TR::CardTemplateRenderingBackSideProblem
|
||||
});
|
||||
let details = localized_template_error(i18n, err);
|
||||
let more_info = i18n.tr(TR::CardTemplateRenderingMoreInfo);
|
||||
let more_info = i18n.card_template_rendering_more_info();
|
||||
let info = format!(
|
||||
"{}<br>{}<br><a href='{}'>{}</a>",
|
||||
header, details, TEMPLATE_ERROR_LINK, more_info
|
||||
@ -566,14 +566,14 @@ pub fn render_card(
|
||||
tr_args!["number"=>card_ord+1]
|
||||
),
|
||||
TEMPLATE_BLANK_CLOZE_LINK,
|
||||
i18n.tr(TR::CardTemplateRenderingMoreInfo)
|
||||
i18n.card_template_rendering_more_info()
|
||||
))
|
||||
} else if !is_cloze && !qtmpl.renders_with_fields(context.nonempty_fields) {
|
||||
Some(format!(
|
||||
"<div>{}<br><a href='{}'>{}</a></div>",
|
||||
i18n.tr(TR::CardTemplateRenderingEmptyFront),
|
||||
i18n.card_template_rendering_empty_front(),
|
||||
TEMPLATE_BLANK_LINK,
|
||||
i18n.tr(TR::CardTemplateRenderingMoreInfo)
|
||||
i18n.card_template_rendering_more_info()
|
||||
))
|
||||
} else {
|
||||
None
|
||||
|
Loading…
Reference in New Issue
Block a user