diff --git a/src/uu/yes/locales/en-US.ftl b/src/uu/yes/locales/en-US.ftl index d4d0806b1..9daaaa820 100644 --- a/src/uu/yes/locales/en-US.ftl +++ b/src/uu/yes/locales/en-US.ftl @@ -1,2 +1,6 @@ yes-about = Repeatedly display a line with STRING (or 'y') yes-usage = yes [STRING]... + +# Error messages +yes-error-standard-output = standard output: { $error } +yes-error-invalid-utf8 = arguments contain invalid UTF-8 diff --git a/src/uu/yes/locales/fr-FR.ftl b/src/uu/yes/locales/fr-FR.ftl new file mode 100644 index 000000000..c3272b809 --- /dev/null +++ b/src/uu/yes/locales/fr-FR.ftl @@ -0,0 +1,6 @@ +yes-about = Affiche de façon répétée une ligne avec CHAÎNE (ou 'y') +yes-usage = yes [CHAÎNE]... + +# Messages d'erreur +yes-error-standard-output = sortie standard : { $error } +yes-error-invalid-utf8 = les arguments contiennent de l'UTF-8 invalide diff --git a/src/uu/yes/src/yes.rs b/src/uu/yes/src/yes.rs index add3f7027..7332297cf 100644 --- a/src/uu/yes/src/yes.rs +++ b/src/uu/yes/src/yes.rs @@ -6,6 +6,7 @@ // cSpell:ignore strs use clap::{Arg, ArgAction, Command, builder::ValueParser}; +use std::collections::HashMap; use std::error::Error; use std::ffi::OsString; use std::io::{self, Write}; @@ -14,7 +15,7 @@ use uucore::format_usage; #[cfg(unix)] use uucore::signals::enable_pipe_errors; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; // it's possible that using a smaller or larger buffer might provide better performance on some // systems, but honestly this is good enough @@ -31,7 +32,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { match exec(&buffer) { Ok(()) => Ok(()), Err(err) if err.kind() == io::ErrorKind::BrokenPipe => Ok(()), - Err(err) => Err(USimpleError::new(1, format!("standard output: {err}"))), + Err(err) => Err(USimpleError::new( + 1, + get_message_with_args( + "yes-error-standard-output", + HashMap::from([("error".to_string(), err.to_string())]), + ), + )), } } @@ -77,7 +84,7 @@ fn args_into_buffer<'a>( for part in itertools::intersperse(i.map(|a| a.to_str()), Some(" ")) { let bytes = match part { Some(part) => part.as_bytes(), - None => return Err("arguments contain invalid UTF-8".into()), + None => return Err(get_message("yes-error-invalid-utf8").into()), }; buf.extend_from_slice(bytes); }