diff --git a/src/uu/nproc/locales/en-US.ftl b/src/uu/nproc/locales/en-US.ftl index 42522997e..0a7b97cc6 100644 --- a/src/uu/nproc/locales/en-US.ftl +++ b/src/uu/nproc/locales/en-US.ftl @@ -2,3 +2,10 @@ nproc-about = Print the number of cores available to the current process. If the OMP_NUM_THREADS or OMP_THREAD_LIMIT environment variables are set, then they will determine the minimum and maximum returned value respectively. nproc-usage = nproc [OPTIONS]... + +# Error messages +nproc-error-invalid-number = { $value } is not a valid number: { $error } + +# Help text for command-line arguments +nproc-help-all = print the number of cores available to the system +nproc-help-ignore = ignore up to N cores diff --git a/src/uu/nproc/locales/fr-FR.ftl b/src/uu/nproc/locales/fr-FR.ftl new file mode 100644 index 000000000..8021cab08 --- /dev/null +++ b/src/uu/nproc/locales/fr-FR.ftl @@ -0,0 +1,11 @@ +nproc-about = Affiche le nombre de cœurs disponibles pour le processus actuel. + Si les variables d'environnement OMP_NUM_THREADS ou OMP_THREAD_LIMIT sont définies, + elles détermineront respectivement la valeur minimale et maximale retournée. +nproc-usage = nproc [OPTIONS]... + +# Messages d'erreur +nproc-error-invalid-number = { $value } n'est pas un nombre valide : { $error } + +# Texte d'aide pour les arguments de ligne de commande +nproc-help-all = affiche le nombre de cœurs disponibles pour le système +nproc-help-ignore = ignore jusqu'à N cœurs diff --git a/src/uu/nproc/src/nproc.rs b/src/uu/nproc/src/nproc.rs index beed92834..f6e84c396 100644 --- a/src/uu/nproc/src/nproc.rs +++ b/src/uu/nproc/src/nproc.rs @@ -6,11 +6,12 @@ // spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr sysconf use clap::{Arg, ArgAction, Command}; +use std::collections::HashMap; use std::{env, thread}; use uucore::display::Quotable; use uucore::error::{UResult, USimpleError}; use uucore::format_usage; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; #[cfg(any(target_os = "linux", target_os = "android"))] pub const _SC_NPROCESSORS_CONF: libc::c_int = 83; @@ -29,12 +30,18 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; let ignore = match matches.get_one::(OPT_IGNORE) { - Some(numstr) => match numstr.trim().parse() { + Some(numstr) => match numstr.trim().parse::() { Ok(num) => num, Err(e) => { return Err(USimpleError::new( 1, - format!("{} is not a valid number: {e}", numstr.quote()), + get_message_with_args( + "nproc-error-invalid-number", + HashMap::from([ + ("value".to_string(), numstr.quote().to_string()), + ("error".to_string(), e.to_string()), + ]), + ), )); } }, @@ -98,14 +105,14 @@ pub fn uu_app() -> Command { .arg( Arg::new(OPT_ALL) .long(OPT_ALL) - .help("print the number of cores available to the system") + .help(get_message("nproc-help-all")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_IGNORE) .long(OPT_IGNORE) .value_name("N") - .help("ignore up to N cores"), + .help(get_message("nproc-help-ignore")), ) }