Skip to content

Commit 45aa9ed

Browse files
committed
l10n: port who to translation + add french
1 parent 320dcd1 commit 45aa9ed

5 files changed

Lines changed: 217 additions & 40 deletions

File tree

src/uu/who/locales/en-US.ftl

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,59 @@ who-usage = who [OPTION]... [ FILE | ARG1 ARG2 ]
33
who-about-musl-warning = Note: When built with musl libc, the `who` utility will not display any
44
information about logged-in users. This is due to musl's stub implementation
55
of `utmpx` functions, which prevents access to the necessary data.
6+
7+
# Long usage help text
8+
who-long-usage = If FILE is not specified, use { $default_file }. /var/log/wtmp as FILE is common.
9+
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.
10+
11+
# Help text for command-line arguments
12+
who-help-all = same as -b -d --login -p -r -t -T -u
13+
who-help-boot = time of last system boot
14+
who-help-dead = print dead processes
15+
who-help-heading = print line of column headings
16+
who-help-login = print system login processes
17+
who-help-lookup = attempt to canonicalize hostnames via DNS
18+
who-help-only-hostname-user = only hostname and user associated with stdin
19+
who-help-process = print active processes spawned by init
20+
who-help-count = all login names and number of users logged on
21+
who-help-runlevel = print current runlevel
22+
who-help-runlevel-non-linux = print current runlevel (This is meaningless on non Linux)
23+
who-help-short = print only name, line, and time (default)
24+
who-help-time = print last system clock change
25+
who-help-users = list users logged in
26+
who-help-mesg = add user's message status as +, - or ?
27+
28+
# Output messages
29+
who-user-count = # { $count ->
30+
[one] user={ $count }
31+
*[other] users={ $count }
32+
}
33+
34+
# Idle time indicators
35+
who-idle-current = .
36+
who-idle-old = old
37+
who-idle-unknown = ?
38+
39+
# System information
40+
who-runlevel = run-level { $level }
41+
who-runlevel-last = last={ $last }
42+
who-clock-change = clock change
43+
who-login = LOGIN
44+
who-login-id = id={ $id }
45+
who-dead-exit-status = term={ $term } exit={ $exit }
46+
who-system-boot = system boot
47+
48+
# Table headings
49+
who-heading-name = NAME
50+
who-heading-line = LINE
51+
who-heading-time = TIME
52+
who-heading-idle = IDLE
53+
who-heading-pid = PID
54+
who-heading-comment = COMMENT
55+
who-heading-exit = EXIT
56+
57+
# Error messages
58+
who-canonicalize-error = failed to canonicalize { $host }
59+
60+
# Platform-specific messages
61+
who-unsupported-openbsd = unsupported command on OpenBSD

src/uu/who/locales/fr-FR.ftl

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
who-about = Affiche des informations sur les utilisateurs actuellement connectés.
2+
who-usage = who [OPTION]... [ FICHIER | ARG1 ARG2 ]
3+
who-about-musl-warning = Note : Lors de la compilation avec musl libc, l'utilitaire `who` n'affichera aucune
4+
information sur les utilisateurs connectés. Ceci est dû à l'implémentation
5+
stub des fonctions `utmpx` de musl, qui empêche l'accès aux données nécessaires.
6+
7+
who-long-usage = Si FICHIER n'est pas spécifié, utilise { $default_file }. /var/log/wtmp comme FICHIER est courant.
8+
Si ARG1 ARG2 sont donnés, -m est présumé : 'am i' ou 'mom likes' sont usuels.
9+
10+
# Help text for command-line arguments
11+
who-help-all = identique à -b -d --login -p -r -t -T -u
12+
who-help-boot = heure du dernier démarrage système
13+
who-help-dead = affiche les processus morts
14+
who-help-heading = affiche une ligne d'en-têtes de colonnes
15+
who-help-login = affiche les processus de connexion système
16+
who-help-lookup = tente de canonicaliser les noms d'hôtes via DNS
17+
who-help-only-hostname-user = seulement le nom d'hôte et l'utilisateur associés à stdin
18+
who-help-process = affiche les processus actifs lancés par init
19+
who-help-count = tous les noms de connexion et le nombre d'utilisateurs connectés
20+
who-help-runlevel = affiche le niveau d'exécution actuel
21+
who-help-runlevel-non-linux = affiche le niveau d'exécution actuel (Sans signification sur non Linux)
22+
who-help-short = affiche seulement nom, ligne et heure (par défaut)
23+
who-help-time = affiche le dernier changement d'horloge système
24+
who-help-users = liste les utilisateurs connectés
25+
who-help-mesg = ajoute le statut de message de l'utilisateur comme +, - ou ?
26+
27+
# Output messages
28+
who-user-count = # { $count ->
29+
[one] utilisateur={ $count }
30+
*[other] utilisateurs={ $count }
31+
}
32+
33+
# Idle time indicators
34+
who-idle-old = anc.
35+
who-idle-unknown = ?
36+
37+
# System information
38+
who-runlevel = niveau-exec { $level }
39+
who-runlevel-last = dernier={ $last }
40+
who-clock-change = changement horloge
41+
who-login = CONNEXION
42+
who-login-id = id={ $id }
43+
who-dead-exit-status = term={ $term } sortie={ $exit }
44+
who-system-boot = démarrage système
45+
46+
# Table headings
47+
who-heading-name = NOM
48+
who-heading-line = LIGNE
49+
who-heading-time = HEURE
50+
who-heading-idle = INACTIF
51+
who-heading-pid = PID
52+
who-heading-comment = COMMENTAIRE
53+
who-heading-exit = SORTIE
54+
55+
# Error messages
56+
who-canonicalize-error = échec de canonicalisation de { $host }
57+
58+
# Platform-specific messages
59+
who-unsupported-openbsd = commande non supportée sur OpenBSD

src/uu/who/src/platform/openbsd.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
use crate::uu_app;
99

1010
use uucore::error::UResult;
11+
use uucore::locale::get_message;
1112

1213
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
1314
let _matches = uu_app().try_get_matches_from(args)?;
14-
15-
println!("unsupported command on OpenBSD");
15+
println!("{}", get_message("who-unsupported-openbsd"));
1616
Ok(())
1717
}

src/uu/who/src/platform/unix.rs

Lines changed: 80 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,20 @@ use crate::uu_app;
1111
use uucore::display::Quotable;
1212
use uucore::error::{FromIo, UResult};
1313
use uucore::libc::{S_IWGRP, STDIN_FILENO, ttyname};
14+
use uucore::locale::{get_message, get_message_with_args};
1415
use uucore::utmpx::{self, Utmpx, time};
1516

1617
use std::borrow::Cow;
18+
use std::collections::HashMap;
1719
use std::ffi::CStr;
1820
use std::fmt::Write;
1921
use std::os::unix::fs::MetadataExt;
2022
use std::path::PathBuf;
2123

2224
fn get_long_usage() -> String {
23-
format!(
24-
"If FILE is not specified, use {}. /var/log/wtmp as FILE is common.\n\
25-
If ARG1 ARG2 given, -m presumed: 'am i' or 'mom likes' are usual.",
26-
utmpx::DEFAULT_FILE,
25+
get_message_with_args(
26+
"who-long-usage",
27+
HashMap::from([("default_file".to_string(), utmpx::DEFAULT_FILE.to_string())]),
2728
)
2829
}
2930

@@ -158,7 +159,7 @@ fn idle_string<'a>(when: i64, boottime: i64) -> Cow<'a, str> {
158159
.into()
159160
}
160161
} else {
161-
" old ".into()
162+
get_message("who-idle-old").into()
162163
}
163164
})
164165
}
@@ -208,7 +209,13 @@ impl Who {
208209
.map(|ut| ut.user())
209210
.collect::<Vec<_>>();
210211
println!("{}", users.join(" "));
211-
println!("# users={}", users.len());
212+
println!(
213+
"{}",
214+
get_message_with_args(
215+
"who-user-count",
216+
HashMap::from([("count".to_string(), users.len().to_string())])
217+
)
218+
);
212219
} else {
213220
let records = Utmpx::iter_all_records_from(f);
214221

@@ -252,8 +259,17 @@ impl Who {
252259
fn print_runlevel(&self, ut: &Utmpx) {
253260
let last = (ut.pid() / 256) as u8 as char;
254261
let curr = (ut.pid() % 256) as u8 as char;
255-
let runlvline = format!("run-level {curr}");
256-
let comment = format!("last={}", if last == 'N' { 'S' } else { 'N' });
262+
let runlvline = get_message_with_args(
263+
"who-runlevel",
264+
HashMap::from([("level".to_string(), curr.to_string())]),
265+
);
266+
let comment = get_message_with_args(
267+
"who-runlevel-last",
268+
HashMap::from([(
269+
"last".to_string(),
270+
(if last == 'N' { 'S' } else { 'N' }).to_string(),
271+
)]),
272+
);
257273

258274
self.print_line(
259275
"",
@@ -269,15 +285,27 @@ impl Who {
269285

270286
#[inline]
271287
fn print_clockchange(&self, ut: &Utmpx) {
272-
self.print_line("", ' ', "clock change", &time_string(ut), "", "", "", "");
288+
self.print_line(
289+
"",
290+
' ',
291+
&get_message("who-clock-change"),
292+
&time_string(ut),
293+
"",
294+
"",
295+
"",
296+
"",
297+
);
273298
}
274299

275300
#[inline]
276301
fn print_login(&self, ut: &Utmpx) {
277-
let comment = format!("id={}", ut.terminal_suffix());
302+
let comment = get_message_with_args(
303+
"who-login-id",
304+
HashMap::from([("id".to_string(), ut.terminal_suffix().to_string())]),
305+
);
278306
let pidstr = format!("{}", ut.pid());
279307
self.print_line(
280-
"LOGIN",
308+
&get_message("who-login"),
281309
' ',
282310
&ut.tty_device(),
283311
&time_string(ut),
@@ -290,10 +318,19 @@ impl Who {
290318

291319
#[inline]
292320
fn print_deadprocs(&self, ut: &Utmpx) {
293-
let comment = format!("id={}", ut.terminal_suffix());
321+
let comment = get_message_with_args(
322+
"who-login-id",
323+
HashMap::from([("id".to_string(), ut.terminal_suffix().to_string())]),
324+
);
294325
let pidstr = format!("{}", ut.pid());
295326
let e = ut.exit_status();
296-
let exitstr = format!("term={} exit={}", e.0, e.1);
327+
let exitstr = get_message_with_args(
328+
"who-dead-exit-status",
329+
HashMap::from([
330+
("term".to_string(), e.0.to_string()),
331+
("exit".to_string(), e.1.to_string()),
332+
]),
333+
);
297334
self.print_line(
298335
"",
299336
' ',
@@ -308,7 +345,10 @@ impl Who {
308345

309346
#[inline]
310347
fn print_initspawn(&self, ut: &Utmpx) {
311-
let comment = format!("id={}", ut.terminal_suffix());
348+
let comment = get_message_with_args(
349+
"who-login-id",
350+
HashMap::from([("id".to_string(), ut.terminal_suffix().to_string())]),
351+
);
312352
let pidstr = format!("{}", ut.pid());
313353
self.print_line(
314354
"",
@@ -324,7 +364,16 @@ impl Who {
324364

325365
#[inline]
326366
fn print_boottime(&self, ut: &Utmpx) {
327-
self.print_line("", ' ', "system boot", &time_string(ut), "", "", "", "");
367+
self.print_line(
368+
"",
369+
' ',
370+
&get_message("who-system-boot"),
371+
&time_string(ut),
372+
"",
373+
"",
374+
"",
375+
"",
376+
);
328377
}
329378

330379
fn print_user(&self, ut: &Utmpx) -> UResult<()> {
@@ -352,18 +401,22 @@ impl Who {
352401
}
353402

354403
let idle = if last_change == 0 {
355-
" ?".into()
404+
get_message("who-idle-unknown").into()
356405
} else {
357406
idle_string(last_change, 0)
358407
};
359408

360409
let s = if self.do_lookup {
361410
ut.canon_host().map_err_context(|| {
362411
let host = ut.host();
363-
format!(
364-
"failed to canonicalize {}",
365-
host.split(':').next().unwrap_or(&host).quote()
412+
get_message_with_args(
413+
"who-canonicalize-error",
414+
HashMap::from([(
415+
"host".to_string(),
416+
host.split(':').next().unwrap_or(&host).quote().to_string(),
417+
)]),
366418
)
419+
.to_string()
367420
})?
368421
} else {
369422
ut.host()
@@ -424,7 +477,14 @@ impl Who {
424477
#[inline]
425478
fn print_heading(&self) {
426479
self.print_line(
427-
"NAME", ' ', "LINE", "TIME", "IDLE", "PID", "COMMENT", "EXIT",
480+
&get_message("who-heading-name"),
481+
' ',
482+
&get_message("who-heading-line"),
483+
&get_message("who-heading-time"),
484+
&get_message("who-heading-idle"),
485+
&get_message("who-heading-pid"),
486+
&get_message("who-heading-comment"),
487+
&get_message("who-heading-exit"),
428488
);
429489
}
430490
}

0 commit comments

Comments
 (0)