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

l10n: port id to translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-03 23:30:54 +02:00 committed by Daniel Hofstetter
parent 1d11f85dd2
commit fa4e46ad15
3 changed files with 195 additions and 55 deletions

View file

@ -8,3 +8,43 @@ id-after-help = The id utility displays the user and group names and numeric IDs
If a user (login name or user ID) is specified, the user and group IDs of If a user (login name or user ID) is specified, the user and group IDs of
that user are displayed. In this case, the real and effective IDs are that user are displayed. In this case, the real and effective IDs are
assumed to be the same. assumed to be the same.
# Context help text
id-context-help-disabled = print only the security context of the process (not enabled)
id-context-help-enabled = print only the security context of the process
# Error messages
id-error-names-real-ids-require-flags = printing only names or real IDs requires -u, -g, or -G
id-error-zero-not-permitted-default = option --zero not permitted in default format
id-error-cannot-print-context-with-user = cannot print security context when user specified
id-error-cannot-get-context = can't get process context
id-error-context-selinux-only = --context (-Z) works only on an SELinux-enabled kernel
id-error-no-such-user = { $user }: no such user
id-error-cannot-find-group-name = cannot find name for group ID { $gid }
id-error-cannot-find-user-name = cannot find name for user ID { $uid }
id-error-audit-retrieve = couldn't retrieve information
# Help text for command-line arguments
id-help-audit = Display the process audit user ID and other process audit properties,
which requires privilege (not available on Linux).
id-help-user = Display only the effective user ID as a number.
id-help-group = Display only the effective group ID as a number
id-help-groups = Display only the different group IDs as white-space separated numbers,
in no particular order.
id-help-human-readable = Make the output human-readable. Each display is on a separate line.
id-help-name = Display the name of the user or group ID for the -G, -g and -u options
instead of the number.
If any of the ID numbers cannot be mapped into
names, the number will be displayed as usual.
id-help-password = Display the id as a password file entry.
id-help-real = Display the real ID for the -G, -g and -u options instead of
the effective ID.
id-help-zero = delimit entries with NUL characters, not whitespace;
not permitted in default format
# Output labels
id-output-uid = uid
id-output-groups = groups
id-output-login = login
id-output-euid = euid
id-output-context = context

View file

@ -0,0 +1,50 @@
id-about = Affiche les informations d'utilisateur et de groupe pour chaque UTILISATEUR spécifié,
ou (si UTILISATEUR est omis) pour l'utilisateur actuel.
id-usage = id [OPTION]... [UTILISATEUR]...
id-after-help = L'utilitaire id affiche les noms d'utilisateur et de groupe ainsi que leurs ID numériques
du processus appelant, vers la sortie standard. Si les ID réels et effectifs sont
différents, les deux sont affichés, sinon seul l'ID réel est affiché.
Si un utilisateur (nom de connexion ou ID utilisateur) est spécifié, les ID utilisateur et groupe
de cet utilisateur sont affichés. Dans ce cas, les ID réels et effectifs sont
supposés être identiques.
# Texte d'aide pour le contexte
id-context-help-disabled = affiche uniquement le contexte de sécurité du processus (non activé)
id-context-help-enabled = affiche uniquement le contexte de sécurité du processus
# Messages d'erreur
id-error-names-real-ids-require-flags = l'affichage des noms uniquement ou des ID réels nécessite -u, -g, ou -G
id-error-zero-not-permitted-default = l'option --zero n'est pas autorisée dans le format par défaut
id-error-cannot-print-context-with-user = impossible d'afficher le contexte de sécurité quand un utilisateur est spécifié
id-error-cannot-get-context = impossible d'obtenir le contexte du processus
id-error-context-selinux-only = --context (-Z) ne fonctionne que sur un noyau avec SELinux activé
id-error-no-such-user = { $user } : utilisateur inexistant
id-error-cannot-find-group-name = impossible de trouver le nom pour l'ID de groupe { $gid }
id-error-cannot-find-user-name = impossible de trouver le nom pour l'ID utilisateur { $uid }
id-error-audit-retrieve = impossible de récupérer les informations
# Texte d'aide pour les arguments de ligne de commande
id-help-audit = Affiche l'ID utilisateur d'audit du processus et autres propriétés d'audit,
ce qui nécessite des privilèges (non disponible sous Linux).
id-help-user = Affiche uniquement l'ID utilisateur effectif sous forme de nombre.
id-help-group = Affiche uniquement l'ID de groupe effectif sous forme de nombre
id-help-groups = Affiche uniquement les différents ID de groupe sous forme de nombres séparés par des espaces,
dans un ordre quelconque.
id-help-human-readable = Rend la sortie lisible par l'humain. Chaque affichage est sur une ligne séparée.
id-help-name = Affiche le nom de l'ID utilisateur ou groupe pour les options -G, -g et -u
au lieu du nombre.
Si certains ID numériques ne peuvent pas être convertis en
noms, le nombre sera affiché comme d'habitude.
id-help-password = Affiche l'id comme une entrée de fichier de mots de passe.
id-help-real = Affiche l'ID réel pour les options -G, -g et -u au lieu de
l'ID effectif.
id-help-zero = délimite les entrées avec des caractères NUL, pas des espaces ;
non autorisé dans le format par défaut
# Étiquettes de sortie
id-output-uid = uid
id-output-groups = groupes
id-output-login = connexion
id-output-euid = euid
id-output-context = contexte

View file

@ -34,6 +34,7 @@
#![allow(dead_code)] #![allow(dead_code)]
use clap::{Arg, ArgAction, Command}; use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::ffi::CStr; use std::ffi::CStr;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::entries::{self, Group, Locate, Passwd}; use uucore::entries::{self, Group, Locate, Passwd};
@ -42,7 +43,7 @@ use uucore::error::{USimpleError, set_exit_code};
pub use uucore::libc; pub use uucore::libc;
use uucore::libc::{getlogin, uid_t}; use uucore::libc::{getlogin, uid_t};
use uucore::line_ending::LineEnding; use uucore::line_ending::LineEnding;
use uucore::locale::get_message; use uucore::locale::{get_message, get_message_with_args};
use uucore::process::{getegid, geteuid, getgid, getuid}; use uucore::process::{getegid, geteuid, getgid, getuid};
use uucore::{format_usage, show_error}; use uucore::{format_usage, show_error};
@ -60,10 +61,12 @@ macro_rules! cstr2cow {
}; };
} }
#[cfg(not(feature = "selinux"))] fn get_context_help_text() -> String {
static CONTEXT_HELP_TEXT: &str = "print only the security context of the process (not enabled)"; #[cfg(not(feature = "selinux"))]
#[cfg(feature = "selinux")] return get_message("id-context-help-disabled");
static CONTEXT_HELP_TEXT: &str = "print only the security context of the process"; #[cfg(feature = "selinux")]
return get_message("id-context-help-enabled");
}
mod options { mod options {
pub const OPT_AUDIT: &str = "audit"; // GNU's id does not have this pub const OPT_AUDIT: &str = "audit"; // GNU's id does not have this
@ -156,20 +159,20 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if (state.nflag || state.rflag) && default_format && !state.cflag { if (state.nflag || state.rflag) && default_format && !state.cflag {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
"printing only names or real IDs requires -u, -g, or -G", get_message("id-error-names-real-ids-require-flags"),
)); ));
} }
if state.zflag && default_format && !state.cflag { if state.zflag && default_format && !state.cflag {
// NOTE: GNU test suite "id/zero.sh" needs this stderr output: // NOTE: GNU test suite "id/zero.sh" needs this stderr output:
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
"option --zero not permitted in default format", get_message("id-error-zero-not-permitted-default"),
)); ));
} }
if state.user_specified && state.cflag { if state.user_specified && state.cflag {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
"cannot print security context when user specified", get_message("id-error-cannot-print-context-with-user"),
)); ));
} }
@ -185,13 +188,16 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
print!("{}{line_ending}", String::from_utf8_lossy(bytes)); print!("{}{line_ending}", String::from_utf8_lossy(bytes));
} else { } else {
// print error because `cflag` was explicitly requested // print error because `cflag` was explicitly requested
return Err(USimpleError::new(1, "can't get process context")); return Err(USimpleError::new(
1,
get_message("id-error-cannot-get-context"),
));
} }
Ok(()) Ok(())
} else { } else {
Err(USimpleError::new( Err(USimpleError::new(
1, 1,
"--context (-Z) works only on an SELinux-enabled kernel", get_message("id-error-context-selinux-only"),
)) ))
}; };
} }
@ -201,7 +207,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
match Passwd::locate(users[i].as_str()) { match Passwd::locate(users[i].as_str()) {
Ok(p) => Some(p), Ok(p) => Some(p),
Err(_) => { Err(_) => {
show_error!("{}: no such user", users[i].quote()); show_error!(
"{}",
get_message_with_args(
"id-error-no-such-user",
HashMap::from([("user".to_string(), users[i].quote().to_string())])
)
);
set_exit_code(1); set_exit_code(1);
if i + 1 >= users.len() { if i + 1 >= users.len() {
break; break;
@ -251,7 +263,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
"{}", "{}",
if state.nflag { if state.nflag {
entries::gid2grp(gid).unwrap_or_else(|_| { entries::gid2grp(gid).unwrap_or_else(|_| {
show_error!("cannot find name for group ID {gid}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-group-name",
HashMap::from([("gid".to_string(), gid.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
gid.to_string() gid.to_string()
}) })
@ -266,7 +284,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
"{}", "{}",
if state.nflag { if state.nflag {
entries::uid2usr(uid).unwrap_or_else(|_| { entries::uid2usr(uid).unwrap_or_else(|_| {
show_error!("cannot find name for user ID {uid}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-user-name",
HashMap::from([("uid".to_string(), uid.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
uid.to_string() uid.to_string()
}) })
@ -291,7 +315,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.map(|&id| { .map(|&id| {
if state.nflag { if state.nflag {
entries::gid2grp(id).unwrap_or_else(|_| { entries::gid2grp(id).unwrap_or_else(|_| {
show_error!("cannot find name for group ID {id}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-group-name",
HashMap::from([("gid".to_string(), id.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
id.to_string() id.to_string()
}) })
@ -341,10 +371,7 @@ pub fn uu_app() -> Command {
options::OPT_GROUPS, options::OPT_GROUPS,
options::OPT_ZERO, options::OPT_ZERO,
]) ])
.help( .help(get_message("id-help-audit"))
"Display the process audit user ID and other process audit properties,\n\
which requires privilege (not available on Linux).",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -352,7 +379,7 @@ pub fn uu_app() -> Command {
.short('u') .short('u')
.long(options::OPT_EFFECTIVE_USER) .long(options::OPT_EFFECTIVE_USER)
.conflicts_with(options::OPT_GROUP) .conflicts_with(options::OPT_GROUP)
.help("Display only the effective user ID as a number.") .help(get_message("id-help-user"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -360,7 +387,7 @@ pub fn uu_app() -> Command {
.short('g') .short('g')
.long(options::OPT_GROUP) .long(options::OPT_GROUP)
.conflicts_with(options::OPT_EFFECTIVE_USER) .conflicts_with(options::OPT_EFFECTIVE_USER)
.help("Display only the effective group ID as a number") .help(get_message("id-help-group"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -375,33 +402,26 @@ pub fn uu_app() -> Command {
options::OPT_PASSWORD, options::OPT_PASSWORD,
options::OPT_AUDIT, options::OPT_AUDIT,
]) ])
.help( .help(get_message("id-help-groups"))
"Display only the different group IDs as white-space separated numbers, \
in no particular order.",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::OPT_HUMAN_READABLE) Arg::new(options::OPT_HUMAN_READABLE)
.short('p') .short('p')
.help("Make the output human-readable. Each display is on a separate line.") .help(get_message("id-help-human-readable"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::OPT_NAME) Arg::new(options::OPT_NAME)
.short('n') .short('n')
.long(options::OPT_NAME) .long(options::OPT_NAME)
.help( .help(get_message("id-help-name"))
"Display the name of the user or group ID for the -G, -g and -u options \
instead of the number.\nIf any of the ID numbers cannot be mapped into \
names, the number will be displayed as usual.",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::OPT_PASSWORD) Arg::new(options::OPT_PASSWORD)
.short('P') .short('P')
.help("Display the id as a password file entry.") .help(get_message("id-help-password"))
.conflicts_with(options::OPT_HUMAN_READABLE) .conflicts_with(options::OPT_HUMAN_READABLE)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
@ -409,20 +429,14 @@ pub fn uu_app() -> Command {
Arg::new(options::OPT_REAL_ID) Arg::new(options::OPT_REAL_ID)
.short('r') .short('r')
.long(options::OPT_REAL_ID) .long(options::OPT_REAL_ID)
.help( .help(get_message("id-help-real"))
"Display the real ID for the -G, -g and -u options instead of \
the effective ID.",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::OPT_ZERO) Arg::new(options::OPT_ZERO)
.short('z') .short('z')
.long(options::OPT_ZERO) .long(options::OPT_ZERO)
.help( .help(get_message("id-help-zero"))
"delimit entries with NUL characters, not whitespace;\n\
not permitted in default format",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -430,7 +444,7 @@ pub fn uu_app() -> Command {
.short('Z') .short('Z')
.long(options::OPT_CONTEXT) .long(options::OPT_CONTEXT)
.conflicts_with_all([options::OPT_GROUP, options::OPT_EFFECTIVE_USER]) .conflicts_with_all([options::OPT_GROUP, options::OPT_EFFECTIVE_USER])
.help(CONTEXT_HELP_TEXT) .help(get_context_help_text())
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -443,7 +457,12 @@ pub fn uu_app() -> Command {
fn pretty(possible_pw: Option<Passwd>) { fn pretty(possible_pw: Option<Passwd>) {
if let Some(p) = possible_pw { if let Some(p) = possible_pw {
print!("uid\t{}\ngroups\t", p.name); print!(
"{}\t{}\n{}\t",
get_message("id-output-uid"),
p.name,
get_message("id-output-groups")
);
println!( println!(
"{}", "{}",
p.belongs_to() p.belongs_to()
@ -457,33 +476,34 @@ fn pretty(possible_pw: Option<Passwd>) {
let rid = getuid(); let rid = getuid();
if let Ok(p) = Passwd::locate(rid) { if let Ok(p) = Passwd::locate(rid) {
if let Some(user_name) = login { if let Some(user_name) = login {
println!("login\t{user_name}"); println!("{}\t{user_name}", get_message("id-output-login"));
} }
println!("uid\t{}", p.name); println!("{}\t{}", get_message("id-output-uid"), p.name);
} else { } else {
println!("uid\t{rid}"); println!("{}\t{rid}", get_message("id-output-uid"));
} }
let eid = getegid(); let eid = getegid();
if eid == rid { if eid == rid {
if let Ok(p) = Passwd::locate(eid) { if let Ok(p) = Passwd::locate(eid) {
println!("euid\t{}", p.name); println!("{}\t{}", get_message("id-output-euid"), p.name);
} else { } else {
println!("euid\t{eid}"); println!("{}\t{eid}", get_message("id-output-euid"));
} }
} }
let rid = getgid(); let rid = getgid();
if rid != eid { if rid != eid {
if let Ok(g) = Group::locate(rid) { if let Ok(g) = Group::locate(rid) {
println!("euid\t{}", g.name); println!("{}\t{}", get_message("id-output-euid"), g.name);
} else { } else {
println!("euid\t{rid}"); println!("{}\t{rid}", get_message("id-output-euid"));
} }
} }
println!( println!(
"groups\t{}", "{}\t{}",
get_message("id-output-groups"),
entries::get_groups_gnu(None) entries::get_groups_gnu(None)
.unwrap() .unwrap()
.iter() .iter()
@ -541,7 +561,7 @@ fn auditid() {
let mut auditinfo: MaybeUninit<audit::c_auditinfo_addr_t> = MaybeUninit::uninit(); let mut auditinfo: MaybeUninit<audit::c_auditinfo_addr_t> = MaybeUninit::uninit();
let address = auditinfo.as_mut_ptr(); let address = auditinfo.as_mut_ptr();
if unsafe { audit::getaudit(address) } < 0 { if unsafe { audit::getaudit(address) } < 0 {
println!("couldn't retrieve information"); println!("{}", get_message("id-error-audit-retrieve"));
return; return;
} }
@ -564,7 +584,13 @@ fn id_print(state: &State, groups: &[u32]) {
print!( print!(
"uid={uid}({})", "uid={uid}({})",
entries::uid2usr(uid).unwrap_or_else(|_| { entries::uid2usr(uid).unwrap_or_else(|_| {
show_error!("cannot find name for user ID {uid}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-user-name",
HashMap::from([("uid".to_string(), uid.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
uid.to_string() uid.to_string()
}) })
@ -572,7 +598,13 @@ fn id_print(state: &State, groups: &[u32]) {
print!( print!(
" gid={gid}({})", " gid={gid}({})",
entries::gid2grp(gid).unwrap_or_else(|_| { entries::gid2grp(gid).unwrap_or_else(|_| {
show_error!("cannot find name for group ID {gid}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-group-name",
HashMap::from([("gid".to_string(), gid.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
gid.to_string() gid.to_string()
}) })
@ -581,7 +613,13 @@ fn id_print(state: &State, groups: &[u32]) {
print!( print!(
" euid={euid}({})", " euid={euid}({})",
entries::uid2usr(euid).unwrap_or_else(|_| { entries::uid2usr(euid).unwrap_or_else(|_| {
show_error!("cannot find name for user ID {euid}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-user-name",
HashMap::from([("uid".to_string(), euid.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
euid.to_string() euid.to_string()
}) })
@ -592,7 +630,13 @@ fn id_print(state: &State, groups: &[u32]) {
print!( print!(
" egid={egid}({})", " egid={egid}({})",
entries::gid2grp(egid).unwrap_or_else(|_| { entries::gid2grp(egid).unwrap_or_else(|_| {
show_error!("cannot find name for group ID {egid}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-group-name",
HashMap::from([("gid".to_string(), egid.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
egid.to_string() egid.to_string()
}) })
@ -605,7 +649,13 @@ fn id_print(state: &State, groups: &[u32]) {
.map(|&gr| format!( .map(|&gr| format!(
"{gr}({})", "{gr}({})",
entries::gid2grp(gr).unwrap_or_else(|_| { entries::gid2grp(gr).unwrap_or_else(|_| {
show_error!("cannot find name for group ID {gr}"); show_error!(
"{}",
get_message_with_args(
"id-error-cannot-find-group-name",
HashMap::from([("gid".to_string(), gr.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
gr.to_string() gr.to_string()
}) })