diff --git a/src/uu/factor/locales/en-US.ftl b/src/uu/factor/locales/en-US.ftl index 07e7920c5..4026313d6 100644 --- a/src/uu/factor/locales/en-US.ftl +++ b/src/uu/factor/locales/en-US.ftl @@ -1,3 +1,12 @@ factor-about = Print the prime factors of the given NUMBER(s). If none are specified, read from standard input. factor-usage = factor [OPTION]... [NUMBER]... + +# Help messages +factor-help-exponents = Print factors in the form p^e +factor-help-help = Print help information. + +# Error messages +factor-error-factorization-incomplete = Factorization incomplete. Remainders exists. +factor-error-write-error = write error +factor-error-reading-input = error reading input: { $error } diff --git a/src/uu/factor/locales/fr-FR.ftl b/src/uu/factor/locales/fr-FR.ftl new file mode 100644 index 000000000..4105e8f5f --- /dev/null +++ b/src/uu/factor/locales/fr-FR.ftl @@ -0,0 +1,12 @@ +factor-about = Afficher les facteurs premiers du/des NOMBRE(s) donné(s). + Si aucun n'est spécifié, lire depuis l'entrée standard. +factor-usage = factor [OPTION]... [NOMBRE]... + +# Messages d'aide +factor-help-exponents = Afficher les facteurs sous la forme p^e +factor-help-help = Afficher les informations d'aide. + +# Messages d'erreur +factor-error-factorization-incomplete = Factorisation incomplète. Des restes existent. +factor-error-write-error = erreur d'écriture +factor-error-reading-input = erreur de lecture de l'entrée : { $error } diff --git a/src/uu/factor/src/factor.rs b/src/uu/factor/src/factor.rs index 4820190f4..2734f9579 100644 --- a/src/uu/factor/src/factor.rs +++ b/src/uu/factor/src/factor.rs @@ -5,7 +5,7 @@ // spell-checker:ignore funcs -use std::collections::BTreeMap; +use std::collections::{BTreeMap, HashMap}; use std::io::BufRead; use std::io::{self, Write, stdin, stdout}; @@ -16,7 +16,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, set_exit_code}; use uucore::{format_usage, show_error, show_warning}; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; mod options { pub static EXPONENTS: &str = "exponents"; @@ -46,11 +46,12 @@ fn print_factors_str( if let Some(_remaining) = remaining { return Err(USimpleError::new( 1, - "Factorization incomplete. Remainders exists.", + get_message("factor-error-factorization-incomplete"), )); } - write_result(w, &x, factorization, print_exponents).map_err_context(|| "write error".into())?; + write_result(w, &x, factorization, print_exponents) + .map_err_context(|| get_message("factor-error-write-error"))?; Ok(()) } @@ -104,7 +105,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } Err(e) => { set_exit_code(1); - show_error!("error reading input: {e}"); + show_error!( + "{}", + get_message_with_args( + "factor-error-reading-input", + HashMap::from([("error".to_string(), e.to_string())]) + ) + ); return Ok(()); } } @@ -131,13 +138,13 @@ pub fn uu_app() -> Command { Arg::new(options::EXPONENTS) .short('h') .long(options::EXPONENTS) - .help("Print factors in the form p^e") + .help(get_message("factor-help-exponents")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::HELP) .long(options::HELP) - .help("Print help information.") + .help(get_message("factor-help-help")) .action(ArgAction::Help), ) }