From e2fa7aff3c25ee9f7846462a3afd1e21d0bc5207 Mon Sep 17 00:00:00 2001 From: Elisabeth Henry Date: Sat, 19 Aug 2023 02:41:12 +0200 Subject: [PATCH] Continue i18n change --- lang/lib/en.yml | 4 ++++ src/lib/book_renderer.rs | 11 ++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lang/lib/en.yml b/lang/lib/en.yml index 70e2941..23cc7c6 100644 --- a/lang/lib/en.yml +++ b/lang/lib/en.yml @@ -9,3 +9,7 @@ error: no_char: "%{s} is not a char" no_i32: "%{s} is not an i32" no_f32: "%{s} is not a f32" + renderer: + no_output: This renderer does not support the auto output + file_creation: "could not create file '%{file}': '%{err}" + write: "could not write book content to file '{file}': {err}" diff --git a/src/lib/book_renderer.rs b/src/lib/book_renderer.rs index 5780576..c977240 100644 --- a/src/lib/book_renderer.rs +++ b/src/lib/book_renderer.rs @@ -21,6 +21,7 @@ use crate::error::{Error, Result, Source}; use std::fs::File; use std::io::Write; use std::path::Path; +use rust_i18n::t; /// Trait that must be implemented by the various renderers to render a whole book. @@ -29,7 +30,7 @@ pub trait BookRenderer: Sync { fn auto_path(&self, _book_file: &str) -> Result { Err(Error::default( Source::empty(), - lformat!("This renderer does not support the auto output"), + t!("error.renderer.no_output"), )) } @@ -47,8 +48,8 @@ pub trait BookRenderer: Sync { let mut file = File::create(path).map_err(|err| { Error::default( Source::empty(), - lformat!( - "could not create file '{file}': {err}", + t!( + "error.renderer.file_creation", file = path.display(), err = err ), @@ -57,8 +58,8 @@ pub trait BookRenderer: Sync { file.write_all(&content).map_err(|err| { Error::default( Source::empty(), - lformat!( - "could not write book content to file '{file}': {err}", + t!( + "error.renderer.write", file = path.display(), err = err ),