1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

l10n: port nproc to translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-04 00:02:13 +02:00
parent 1d11f85dd2
commit 991144a79a
3 changed files with 30 additions and 5 deletions

View file

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

View file

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

View file

@ -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::<String>(OPT_IGNORE) {
Some(numstr) => match numstr.trim().parse() {
Some(numstr) => match numstr.trim().parse::<usize>() {
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")),
)
}