From c45ab78b73299cf5b58a3f33eaddae106f09aaa5 Mon Sep 17 00:00:00 2001 From: Damien Elmes Date: Sat, 27 Mar 2021 10:49:40 +1000 Subject: [PATCH] update multi-arg TR references, where some needed reordering --- rslib/src/backend/progress.rs | 14 ++++++------ rslib/src/err.rs | 40 +++++++++++++++-------------------- rslib/src/media/check.rs | 7 ++---- rslib/src/template.rs | 6 +++--- 4 files changed, 28 insertions(+), 39 deletions(-) diff --git a/rslib/src/backend/progress.rs b/rslib/src/backend/progress.rs index 7b3544712..45b39fe31 100644 --- a/rslib/src/backend/progress.rs +++ b/rslib/src/backend/progress.rs @@ -119,14 +119,12 @@ pub(super) fn progress_to_proto(progress: Option, i18n: &I18n) -> pb:: fn media_sync_progress(p: MediaSyncProgress, i18n: &I18n) -> pb::progress::MediaSync { pb::progress::MediaSync { checked: i18n.sync_media_checked_count(p.checked).into(), - added: i18n.trn( - TR::SyncMediaAddedCount, - tr_args!["up"=>p.uploaded_files,"down"=>p.downloaded_files], - ), - removed: i18n.trn( - TR::SyncMediaRemovedCount, - tr_args!["up"=>p.uploaded_deletions,"down"=>p.downloaded_deletions], - ), + added: i18n + .sync_media_added_count(p.uploaded_files, p.downloaded_files) + .into(), + removed: i18n + .sync_media_removed_count(p.uploaded_deletions, p.downloaded_deletions) + .into(), } } diff --git a/rslib/src/err.rs b/rslib/src/err.rs index aaee2faca..28a4cb185 100644 --- a/rslib/src/err.rs +++ b/rslib/src/err.rs @@ -142,17 +142,11 @@ impl AnkiError { i18n.search_unknown_escape(ctx.replace('`', "'")).into() } SearchErrorKind::InvalidState(state) => i18n - .trn( - TR::SearchInvalidArgument, - tr_strs!("term" => "is:", "argument" => state.replace('`', "'")), - ) + .search_invalid_argument("is:", state.replace('`', "'")) .into(), SearchErrorKind::InvalidFlag => i18n.search_invalid_flag(), SearchErrorKind::InvalidPropProperty(prop) => i18n - .trn( - TR::SearchInvalidArgument, - tr_strs!("term" => "prop:", "argument" => prop.replace('`', "'")), - ) + .search_invalid_argument("prop:", prop.replace('`', "'")) .into(), SearchErrorKind::InvalidPropOperator(ctx) => { i18n.search_invalid_prop_operator(ctx.as_str()).into() @@ -163,33 +157,33 @@ impl AnkiError { SearchErrorKind::Other(Some(info)) => info.into(), SearchErrorKind::Other(None) => i18n.search_invalid_other(), SearchErrorKind::InvalidNumber { provided, context } => i18n - .trn( - TR::SearchInvalidNumber, - tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], + .search_invalid_number( + context.replace('`', "'"), + provided.replace('`', "'"), ) .into(), SearchErrorKind::InvalidWholeNumber { provided, context } => i18n - .trn( - TR::SearchInvalidWholeNumber, - tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], + .search_invalid_whole_number( + context.replace('`', "'"), + provided.replace('`', "'"), ) .into(), SearchErrorKind::InvalidPositiveWholeNumber { provided, context } => i18n - .trn( - TR::SearchInvalidPositiveWholeNumber, - tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], + .search_invalid_positive_whole_number( + context.replace('`', "'"), + provided.replace('`', "'"), ) .into(), SearchErrorKind::InvalidNegativeWholeNumber { provided, context } => i18n - .trn( - TR::SearchInvalidNegativeWholeNumber, - tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], + .search_invalid_negative_whole_number( + context.replace('`', "'"), + provided.replace('`', "'"), ) .into(), SearchErrorKind::InvalidAnswerButton { provided, context } => i18n - .trn( - TR::SearchInvalidAnswerButton, - tr_strs!["provided"=>provided.replace('`', "'"), "context"=>context.replace('`', "'")], + .search_invalid_answer_button( + context.replace('`', "'"), + provided.replace('`', "'"), ) .into(), }; diff --git a/rslib/src/media/check.rs b/rslib/src/media/check.rs index f6235bf8e..64a8dd9b2 100644 --- a/rslib/src/media/check.rs +++ b/rslib/src/media/check.rs @@ -94,10 +94,7 @@ where // top summary area if output.trash_count > 0 { let megs = (output.trash_bytes as f32) / 1024.0 / 1024.0; - buf += &i.trn( - TR::MediaCheckTrashCount, - tr_args!["count"=>output.trash_count, "megs"=>megs], - ); + buf += &i.media_check_trash_count(output.trash_count, megs); buf.push('\n'); } @@ -126,7 +123,7 @@ where 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]); + buf += &i.media_check_renamed_file(old.as_str(), new.as_str()); buf.push('\n'); } buf.push('\n') diff --git a/rslib/src/template.rs b/rslib/src/template.rs index f5404889c..b898c77ac 100644 --- a/rslib/src/template.rs +++ b/rslib/src/template.rs @@ -264,9 +264,9 @@ fn template_error_to_anki_error(err: TemplateError, q_side: bool, i18n: &I18n) - fn localized_template_error(i18n: &I18n, err: TemplateError) -> String { match err { - TemplateError::NoClosingBrackets(tag) => i18n.trn( - TR::CardTemplateRenderingNoClosingBrackets, - tr_strs!("tag"=>tag, "missing"=>"}}"), + TemplateError::NoClosingBrackets(tag) => i18n + .card_template_rendering_no_closing_brackets("}}", tag) + .into(), TemplateError::ConditionalNotClosed(tag) => i18n .card_template_rendering_conditional_not_closed(format!("{{{{/{}}}}}", tag)) .into(),