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

l10n: port who to translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-04 23:02:28 +02:00
parent 320dcd114c
commit 45aa9edfbd
5 changed files with 217 additions and 40 deletions

View file

@ -3,3 +3,59 @@ who-usage = who [OPTION]... [ FILE | ARG1 ARG2 ]
who-about-musl-warning = Note: When built with musl libc, the `who` utility will not display any
information about logged-in users. This is due to musl's stub implementation
of `utmpx` functions, which prevents access to the necessary data.
# Long usage help text
who-long-usage = If FILE is not specified, use { $default_file }. /var/log/wtmp as FILE is common.
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.
# Help text for command-line arguments
who-help-all = same as -b -d --login -p -r -t -T -u
who-help-boot = time of last system boot
who-help-dead = print dead processes
who-help-heading = print line of column headings
who-help-login = print system login processes
who-help-lookup = attempt to canonicalize hostnames via DNS
who-help-only-hostname-user = only hostname and user associated with stdin
who-help-process = print active processes spawned by init
who-help-count = all login names and number of users logged on
who-help-runlevel = print current runlevel
who-help-runlevel-non-linux = print current runlevel (This is meaningless on non Linux)
who-help-short = print only name, line, and time (default)
who-help-time = print last system clock change
who-help-users = list users logged in
who-help-mesg = add user's message status as +, - or ?
# Output messages
who-user-count = # { $count ->
[one] user={ $count }
*[other] users={ $count }
}
# Idle time indicators
who-idle-current = .
who-idle-old = old
who-idle-unknown = ?
# System information
who-runlevel = run-level { $level }
who-runlevel-last = last={ $last }
who-clock-change = clock change
who-login = LOGIN
who-login-id = id={ $id }
who-dead-exit-status = term={ $term } exit={ $exit }
who-system-boot = system boot
# Table headings
who-heading-name = NAME
who-heading-line = LINE
who-heading-time = TIME
who-heading-idle = IDLE
who-heading-pid = PID
who-heading-comment = COMMENT
who-heading-exit = EXIT
# Error messages
who-canonicalize-error = failed to canonicalize { $host }
# Platform-specific messages
who-unsupported-openbsd = unsupported command on OpenBSD

View file

@ -0,0 +1,59 @@
who-about = Affiche des informations sur les utilisateurs actuellement connectés.
who-usage = who [OPTION]... [ FICHIER | ARG1 ARG2 ]
who-about-musl-warning = Note : Lors de la compilation avec musl libc, l'utilitaire `who` n'affichera aucune
information sur les utilisateurs connectés. Ceci est dû à l'implémentation
stub des fonctions `utmpx` de musl, qui empêche l'accès aux données nécessaires.
who-long-usage = Si FICHIER n'est pas spécifié, utilise { $default_file }. /var/log/wtmp comme FICHIER est courant.
Si ARG1 ARG2 sont donnés, -m est présumé : 'am i' ou 'mom likes' sont usuels.
# Help text for command-line arguments
who-help-all = identique à -b -d --login -p -r -t -T -u
who-help-boot = heure du dernier démarrage système
who-help-dead = affiche les processus morts
who-help-heading = affiche une ligne d'en-têtes de colonnes
who-help-login = affiche les processus de connexion système
who-help-lookup = tente de canonicaliser les noms d'hôtes via DNS
who-help-only-hostname-user = seulement le nom d'hôte et l'utilisateur associés à stdin
who-help-process = affiche les processus actifs lancés par init
who-help-count = tous les noms de connexion et le nombre d'utilisateurs connectés
who-help-runlevel = affiche le niveau d'exécution actuel
who-help-runlevel-non-linux = affiche le niveau d'exécution actuel (Sans signification sur non Linux)
who-help-short = affiche seulement nom, ligne et heure (par défaut)
who-help-time = affiche le dernier changement d'horloge système
who-help-users = liste les utilisateurs connectés
who-help-mesg = ajoute le statut de message de l'utilisateur comme +, - ou ?
# Output messages
who-user-count = # { $count ->
[one] utilisateur={ $count }
*[other] utilisateurs={ $count }
}
# Idle time indicators
who-idle-old = anc.
who-idle-unknown = ?
# System information
who-runlevel = niveau-exec { $level }
who-runlevel-last = dernier={ $last }
who-clock-change = changement horloge
who-login = CONNEXION
who-login-id = id={ $id }
who-dead-exit-status = term={ $term } sortie={ $exit }
who-system-boot = démarrage système
# Table headings
who-heading-name = NOM
who-heading-line = LIGNE
who-heading-time = HEURE
who-heading-idle = INACTIF
who-heading-pid = PID
who-heading-comment = COMMENTAIRE
who-heading-exit = SORTIE
# Error messages
who-canonicalize-error = échec de canonicalisation de { $host }
# Platform-specific messages
who-unsupported-openbsd = commande non supportée sur OpenBSD

View file

@ -8,10 +8,10 @@
use crate::uu_app;
use uucore::error::UResult;
use uucore::locale::get_message;
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let _matches = uu_app().try_get_matches_from(args)?;
println!("unsupported command on OpenBSD");
println!("{}", get_message("who-unsupported-openbsd"));
Ok(())
}

View file

@ -11,19 +11,20 @@ use crate::uu_app;
use uucore::display::Quotable;
use uucore::error::{FromIo, UResult};
use uucore::libc::{S_IWGRP, STDIN_FILENO, ttyname};
use uucore::locale::{get_message, get_message_with_args};
use uucore::utmpx::{self, Utmpx, time};
use std::borrow::Cow;
use std::collections::HashMap;
use std::ffi::CStr;
use std::fmt::Write;
use std::os::unix::fs::MetadataExt;
use std::path::PathBuf;
fn get_long_usage() -> String {
format!(
"If FILE is not specified, use {}. /var/log/wtmp as FILE is common.\n\
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.",
utmpx::DEFAULT_FILE,
get_message_with_args(
"who-long-usage",
HashMap::from([("default_file".to_string(), utmpx::DEFAULT_FILE.to_string())]),
)
}
@ -158,7 +159,7 @@ fn idle_string<'a>(when: i64, boottime: i64) -> Cow<'a, str> {
.into()
}
} else {
" old ".into()
get_message("who-idle-old").into()
}
})
}
@ -208,7 +209,13 @@ impl Who {
.map(|ut| ut.user())
.collect::<Vec<_>>();
println!("{}", users.join(" "));
println!("# users={}", users.len());
println!(
"{}",
get_message_with_args(
"who-user-count",
HashMap::from([("count".to_string(), users.len().to_string())])
)
);
} else {
let records = Utmpx::iter_all_records_from(f);
@ -252,8 +259,17 @@ impl Who {
fn print_runlevel(&self, ut: &Utmpx) {
let last = (ut.pid() / 256) as u8 as char;
let curr = (ut.pid() % 256) as u8 as char;
let runlvline = format!("run-level {curr}");
let comment = format!("last={}", if last == 'N' { 'S' } else { 'N' });
let runlvline = get_message_with_args(
"who-runlevel",
HashMap::from([("level".to_string(), curr.to_string())]),
);
let comment = get_message_with_args(
"who-runlevel-last",
HashMap::from([(
"last".to_string(),
(if last == 'N' { 'S' } else { 'N' }).to_string(),
)]),
);
self.print_line(
"",
@ -269,15 +285,27 @@ impl Who {
#[inline]
fn print_clockchange(&self, ut: &Utmpx) {
self.print_line("", ' ', "clock change", &time_string(ut), "", "", "", "");
self.print_line(
"",
' ',
&get_message("who-clock-change"),
&time_string(ut),
"",
"",
"",
"",
);
}
#[inline]
fn print_login(&self, ut: &Utmpx) {
let comment = format!("id={}", ut.terminal_suffix());
let comment = get_message_with_args(
"who-login-id",
HashMap::from([("id".to_string(), ut.terminal_suffix().to_string())]),
);
let pidstr = format!("{}", ut.pid());
self.print_line(
"LOGIN",
&get_message("who-login"),
' ',
&ut.tty_device(),
&time_string(ut),
@ -290,10 +318,19 @@ impl Who {
#[inline]
fn print_deadprocs(&self, ut: &Utmpx) {
let comment = format!("id={}", ut.terminal_suffix());
let comment = get_message_with_args(
"who-login-id",
HashMap::from([("id".to_string(), ut.terminal_suffix().to_string())]),
);
let pidstr = format!("{}", ut.pid());
let e = ut.exit_status();
let exitstr = format!("term={} exit={}", e.0, e.1);
let exitstr = get_message_with_args(
"who-dead-exit-status",
HashMap::from([
("term".to_string(), e.0.to_string()),
("exit".to_string(), e.1.to_string()),
]),
);
self.print_line(
"",
' ',
@ -308,7 +345,10 @@ impl Who {
#[inline]
fn print_initspawn(&self, ut: &Utmpx) {
let comment = format!("id={}", ut.terminal_suffix());
let comment = get_message_with_args(
"who-login-id",
HashMap::from([("id".to_string(), ut.terminal_suffix().to_string())]),
);
let pidstr = format!("{}", ut.pid());
self.print_line(
"",
@ -324,7 +364,16 @@ impl Who {
#[inline]
fn print_boottime(&self, ut: &Utmpx) {
self.print_line("", ' ', "system boot", &time_string(ut), "", "", "", "");
self.print_line(
"",
' ',
&get_message("who-system-boot"),
&time_string(ut),
"",
"",
"",
"",
);
}
fn print_user(&self, ut: &Utmpx) -> UResult<()> {
@ -352,7 +401,7 @@ impl Who {
}
let idle = if last_change == 0 {
" ?".into()
get_message("who-idle-unknown").into()
} else {
idle_string(last_change, 0)
};
@ -360,10 +409,14 @@ impl Who {
let s = if self.do_lookup {
ut.canon_host().map_err_context(|| {
let host = ut.host();
format!(
"failed to canonicalize {}",
host.split(':').next().unwrap_or(&host).quote()
get_message_with_args(
"who-canonicalize-error",
HashMap::from([(
"host".to_string(),
host.split(':').next().unwrap_or(&host).quote().to_string(),
)]),
)
.to_string()
})?
} else {
ut.host()
@ -424,7 +477,14 @@ impl Who {
#[inline]
fn print_heading(&self) {
self.print_line(
"NAME", ' ', "LINE", "TIME", "IDLE", "PID", "COMMENT", "EXIT",
&get_message("who-heading-name"),
' ',
&get_message("who-heading-line"),
&get_message("who-heading-time"),
&get_message("who-heading-idle"),
&get_message("who-heading-pid"),
&get_message("who-heading-comment"),
&get_message("who-heading-exit"),
);
}
}

View file

@ -29,10 +29,12 @@ mod options {
pub const FILE: &str = "FILE"; // if length=1: FILE, if length=2: ARG1 ARG2
}
fn get_runlevel_help() -> String {
#[cfg(target_os = "linux")]
static RUNLEVEL_HELP: &str = "print current runlevel";
return get_message("who-help-runlevel");
#[cfg(not(target_os = "linux"))]
static RUNLEVEL_HELP: &str = "print current runlevel (This is meaningless on non Linux)";
return get_message("who-help-runlevel-non-linux");
}
#[uucore::main]
use platform::uumain;
@ -52,89 +54,89 @@ pub fn uu_app() -> Command {
Arg::new(options::ALL)
.long(options::ALL)
.short('a')
.help("same as -b -d --login -p -r -t -T -u")
.help(get_message("who-help-all"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::BOOT)
.long(options::BOOT)
.short('b')
.help("time of last system boot")
.help(get_message("who-help-boot"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::DEAD)
.long(options::DEAD)
.short('d')
.help("print dead processes")
.help(get_message("who-help-dead"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::HEADING)
.long(options::HEADING)
.short('H')
.help("print line of column headings")
.help(get_message("who-help-heading"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::LOGIN)
.long(options::LOGIN)
.short('l')
.help("print system login processes")
.help(get_message("who-help-login"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::LOOKUP)
.long(options::LOOKUP)
.help("attempt to canonicalize hostnames via DNS")
.help(get_message("who-help-lookup"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::ONLY_HOSTNAME_USER)
.short('m')
.help("only hostname and user associated with stdin")
.help(get_message("who-help-only-hostname-user"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::PROCESS)
.long(options::PROCESS)
.short('p')
.help("print active processes spawned by init")
.help(get_message("who-help-process"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::COUNT)
.long(options::COUNT)
.short('q')
.help("all login names and number of users logged on")
.help(get_message("who-help-count"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::RUNLEVEL)
.long(options::RUNLEVEL)
.short('r')
.help(RUNLEVEL_HELP)
.help(get_runlevel_help())
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::SHORT)
.long(options::SHORT)
.short('s')
.help("print only name, line, and time (default)")
.help(get_message("who-help-short"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::TIME)
.long(options::TIME)
.short('t')
.help("print last system clock change")
.help(get_message("who-help-time"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::USERS)
.long(options::USERS)
.short('u')
.help("list users logged in")
.help(get_message("who-help-users"))
.action(ArgAction::SetTrue),
)
.arg(
@ -143,7 +145,7 @@ pub fn uu_app() -> Command {
.short('T')
.visible_short_alias('w')
.visible_aliases(["message", "writable"])
.help("add user's message status as +, - or ?")
.help(get_message("who-help-mesg"))
.action(ArgAction::SetTrue),
)
.arg(