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

Merge pull request #8077 from sylvestre/l10n-proc

l10n: port nproc to translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-06 11:25:10 +02:00 committed by GitHub
commit 246a7e533d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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 If the OMP_NUM_THREADS or OMP_THREAD_LIMIT environment variables are set, then
they will determine the minimum and maximum returned value respectively. they will determine the minimum and maximum returned value respectively.
nproc-usage = nproc [OPTIONS]... 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 // spell-checker:ignore (ToDO) NPROCESSORS nprocs numstr sysconf
use clap::{Arg, ArgAction, Command}; use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::{env, thread}; use std::{env, thread};
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
use uucore::format_usage; 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"))] #[cfg(any(target_os = "linux", target_os = "android"))]
pub const _SC_NPROCESSORS_CONF: libc::c_int = 83; 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 matches = uu_app().try_get_matches_from(args)?;
let ignore = match matches.get_one::<String>(OPT_IGNORE) { 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, Ok(num) => num,
Err(e) => { Err(e) => {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 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(
Arg::new(OPT_ALL) Arg::new(OPT_ALL)
.long(OPT_ALL) .long(OPT_ALL)
.help("print the number of cores available to the system") .help(get_message("nproc-help-all"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(OPT_IGNORE) Arg::new(OPT_IGNORE)
.long(OPT_IGNORE) .long(OPT_IGNORE)
.value_name("N") .value_name("N")
.help("ignore up to N cores"), .help(get_message("nproc-help-ignore")),
) )
} }