1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

l10n: port factor for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-17 22:02:46 +02:00
parent bcb76aca64
commit f378f081a7
3 changed files with 35 additions and 7 deletions

View file

@ -1,3 +1,12 @@
factor-about = Print the prime factors of the given NUMBER(s). factor-about = Print the prime factors of the given NUMBER(s).
If none are specified, read from standard input. If none are specified, read from standard input.
factor-usage = factor [OPTION]... [NUMBER]... 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 }

View file

@ -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 }

View file

@ -5,7 +5,7 @@
// spell-checker:ignore funcs // spell-checker:ignore funcs
use std::collections::BTreeMap; use std::collections::{BTreeMap, HashMap};
use std::io::BufRead; use std::io::BufRead;
use std::io::{self, Write, stdin, stdout}; 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::error::{FromIo, UResult, USimpleError, set_exit_code};
use uucore::{format_usage, show_error, show_warning}; use uucore::{format_usage, show_error, show_warning};
use uucore::locale::get_message; use uucore::locale::{get_message, get_message_with_args};
mod options { mod options {
pub static EXPONENTS: &str = "exponents"; pub static EXPONENTS: &str = "exponents";
@ -46,11 +46,12 @@ fn print_factors_str(
if let Some(_remaining) = remaining { if let Some(_remaining) = remaining {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 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(()) Ok(())
} }
@ -104,7 +105,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
} }
Err(e) => { Err(e) => {
set_exit_code(1); 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(()); return Ok(());
} }
} }
@ -131,13 +138,13 @@ pub fn uu_app() -> Command {
Arg::new(options::EXPONENTS) Arg::new(options::EXPONENTS)
.short('h') .short('h')
.long(options::EXPONENTS) .long(options::EXPONENTS)
.help("Print factors in the form p^e") .help(get_message("factor-help-exponents"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::HELP) Arg::new(options::HELP)
.long(options::HELP) .long(options::HELP)
.help("Print help information.") .help(get_message("factor-help-help"))
.action(ArgAction::Help), .action(ArgAction::Help),
) )
} }