Skip to content

Commit b30e6f8

Browse files
committed
l10n: port df for translation + add french
1 parent 1675c3e commit b30e6f8

File tree

5 files changed

+222
-61
lines changed

5 files changed

+222
-61
lines changed

.vscode/cspell.dictionaries/workspace.wordlist.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ getrandom
2525
globset
2626
indicatif
2727
itertools
28+
iuse
2829
langid
2930
lscolors
3031
mdbook

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,53 @@ df-after-help = Display values are in units of the first available SIZE from --b
88
SIZE is an integer and optional unit (example: 10M is 10*1024*1024).
99
Units are K, M, G, T, P, E, Z, Y (powers of 1024) or KB, MB,... (powers
1010
of 1000).
11+
12+
# Help messages
13+
df-help-print-help = Print help information.
14+
df-help-all = include dummy file systems
15+
df-help-block-size = scale sizes by SIZE before printing them; e.g. '-BM' prints sizes in units of 1,048,576 bytes
16+
df-help-total = produce a grand total
17+
df-help-human-readable = print sizes in human readable format (e.g., 1K 234M 2G)
18+
df-help-si = likewise, but use powers of 1000 not 1024
19+
df-help-inodes = list inode information instead of block usage
20+
df-help-kilo = like --block-size=1K
21+
df-help-local = limit listing to local file systems
22+
df-help-no-sync = do not invoke sync before getting usage info (default)
23+
df-help-output = use output format defined by FIELD_LIST, or print all fields if FIELD_LIST is omitted.
24+
df-help-portability = use the POSIX output format
25+
df-help-sync = invoke sync before getting usage info (non-windows only)
26+
df-help-type = limit listing to file systems of type TYPE
27+
df-help-print-type = print file system type
28+
df-help-exclude-type = limit listing to file systems not of type TYPE
29+
30+
# Error messages
31+
df-error-block-size-too-large = --block-size argument '{ $size }' too large
32+
df-error-invalid-block-size = invalid --block-size argument { $size }
33+
df-error-invalid-suffix = invalid suffix in --block-size argument { $size }
34+
df-error-field-used-more-than-once = option --output: field { $field } used more than once
35+
df-error-filesystem-type-both-selected-and-excluded = file system type { $type } both selected and excluded
36+
df-error-no-such-file-or-directory = { $path }: No such file or directory
37+
df-error-no-file-systems-processed = no file systems processed
38+
df-error-cannot-access-over-mounted = cannot access { $path }: over-mounted by another device
39+
df-error-cannot-read-table-of-mounted-filesystems = cannot read table of mounted file systems
40+
df-error-inodes-not-supported-windows = { $program }: doesn't support -i option
41+
42+
# Headers
43+
df-header-filesystem = Filesystem
44+
df-header-size = Size
45+
df-header-used = Used
46+
df-header-avail = Avail
47+
df-header-available = Available
48+
df-header-use-percent = Use%
49+
df-header-capacity = Capacity
50+
df-header-mounted-on = Mounted on
51+
df-header-inodes = Inodes
52+
df-header-iused = IUsed
53+
df-header-iavail = IFree
54+
df-header-iuse-percent = IUse%
55+
df-header-file = File
56+
df-header-type = Type
57+
58+
# Other
59+
df-total = total
60+
df-blocks-suffix = -blocks

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

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
df-about = afficher des informations sur le système de fichiers sur lequel chaque FICHIER réside,
2+
ou tous les systèmes de fichiers par défaut.
3+
df-usage = df [OPTION]... [FICHIER]...
4+
df-after-help = Les valeurs affichées sont en unités de la première TAILLE disponible de --block-size,
5+
et des variables d'environnement DF_BLOCK_SIZE, BLOCK_SIZE et BLOCKSIZE.
6+
Sinon, les unités par défaut sont 1024 octets (ou 512 si POSIXLY_CORRECT est défini).
7+
8+
TAILLE est un entier et une unité optionnelle (exemple : 10M est 10*1024*1024).
9+
Les unités sont K, M, G, T, P, E, Z, Y (puissances de 1024) ou KB, MB,... (puissances
10+
de 1000).
11+
12+
# Messages d'aide
13+
df-help-print-help = afficher les informations d'aide.
14+
df-help-all = inclure les systèmes de fichiers factices
15+
df-help-block-size = mettre les tailles à l'échelle par TAILLE avant de les afficher ; par ex. '-BM' affiche les tailles en unités de 1 048 576 octets
16+
df-help-total = produire un total général
17+
df-help-human-readable = afficher les tailles dans un format lisible par l'homme (par ex., 1K 234M 2G)
18+
df-help-si = pareillement, mais utiliser les puissances de 1000 pas 1024
19+
df-help-inodes = lister les informations d'inode au lieu de l'utilisation des blocs
20+
df-help-kilo = comme --block-size=1K
21+
df-help-local = limiter l'affichage aux systèmes de fichiers locaux
22+
df-help-no-sync = ne pas invoquer sync avant d'obtenir les informations d'utilisation (par défaut)
23+
df-help-output = utiliser le format de sortie défini par LISTE_CHAMPS, ou afficher tous les champs si LISTE_CHAMPS est omise.
24+
df-help-portability = utiliser le format de sortie POSIX
25+
df-help-sync = invoquer sync avant d'obtenir les informations d'utilisation (non-windows seulement)
26+
df-help-type = limiter l'affichage aux systèmes de fichiers de type TYPE
27+
df-help-print-type = afficher le type de système de fichiers
28+
df-help-exclude-type = limiter l'affichage aux systèmes de fichiers pas de type TYPE
29+
30+
# Messages d'erreur
31+
df-error-block-size-too-large = argument --block-size '{ $size }' trop grand
32+
df-error-invalid-block-size = argument --block-size invalide { $size }
33+
df-error-invalid-suffix = suffixe invalide dans l'argument --block-size { $size }
34+
df-error-field-used-more-than-once = option --output : champ { $field } utilisé plus d'une fois
35+
df-error-filesystem-type-both-selected-and-excluded = type de système de fichiers { $type } à la fois sélectionné et exclu
36+
df-error-no-such-file-or-directory = { $path } : aucun fichier ou répertoire de ce type
37+
df-error-no-file-systems-processed = aucun système de fichiers traité
38+
df-error-cannot-access-over-mounted = impossible d'accéder à { $path } : sur-monté par un autre périphérique
39+
df-error-cannot-read-table-of-mounted-filesystems = impossible de lire la table des systèmes de fichiers montés
40+
df-error-inodes-not-supported-windows = { $program } : ne supporte pas l'option -i
41+
42+
# En-têtes du tableau
43+
df-header-filesystem = Sys. de fichiers
44+
df-header-size = Taille
45+
df-header-used = Utilisé
46+
df-header-avail = Disp.
47+
df-header-available = Disponible
48+
df-header-use-percent = Util%
49+
df-header-capacity = Capacité
50+
df-header-mounted-on = Monté sur
51+
df-header-inodes = Inodes
52+
df-header-iused = IUtil
53+
df-header-iavail = ILibre
54+
df-header-iuse-percent = IUtil%
55+
df-header-file = Fichier
56+
df-header-type = Type
57+
58+
# Autres messages
59+
df-total = total
60+
df-blocks-suffix = -blocs

src/uu/df/src/df.rs

Lines changed: 56 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ use crate::filesystem::Filesystem;
2929
use crate::filesystem::FsError;
3030
use crate::table::Table;
3131

32-
use uucore::locale::get_message;
32+
use std::collections::HashMap;
33+
use uucore::locale::{get_message, get_message_with_args};
3334

3435
static OPT_HELP: &str = "help";
3536
static OPT_ALL: &str = "all";
@@ -115,25 +116,28 @@ impl Default for Options {
115116
enum OptionsError {
116117
// TODO This needs to vary based on whether `--block-size`
117118
// or `-B` were provided.
118-
#[error("--block-size argument '{0}' too large")]
119+
#[error("{}", get_message_with_args("df-error-block-size-too-large", HashMap::from([("size".to_string(), .0.clone())])))]
119120
BlockSizeTooLarge(String),
120121
// TODO This needs to vary based on whether `--block-size`
121122
// or `-B` were provided.,
122-
#[error("invalid --block-size argument {0}")]
123+
#[error("{}", get_message_with_args("df-error-invalid-block-size", HashMap::from([("size".to_string(), .0.clone())])))]
123124
InvalidBlockSize(String),
124125
// TODO This needs to vary based on whether `--block-size`
125126
// or `-B` were provided.
126-
#[error("invalid suffix in --block-size argument {0}")]
127+
#[error("{}", get_message_with_args("df-error-invalid-suffix", HashMap::from([("size".to_string(), .0.clone())])))]
127128
InvalidSuffix(String),
128129

129130
/// An error getting the columns to display in the output table.
130-
#[error("option --output: field {0} used more than once")]
131+
#[error("{}", get_message_with_args("df-error-field-used-more-than-once", HashMap::from([("field".to_string(), format!("{}", .0))])))]
131132
ColumnError(ColumnError),
132133

133-
#[error("{}", .0.iter()
134-
.map(|t| format!("file system type {} both selected and excluded", t.quote()))
134+
#[error(
135+
"{}",
136+
.0.iter()
137+
.map(|t| get_message_with_args("df-error-filesystem-type-both-selected-and-excluded", HashMap::from([("type".to_string(), t.quote().to_string())])))
135138
.collect::<Vec<_>>()
136-
.join(format!("\n{}: ", uucore::util_name()).as_str()))]
139+
.join(format!("\n{}: ", uucore::util_name()).as_str())
140+
)]
137141
FilesystemTypeBothSelectedAndExcluded(Vec<String>),
138142
}
139143

@@ -359,26 +363,35 @@ where
359363
Err(FsError::InvalidPath) => {
360364
show!(USimpleError::new(
361365
1,
362-
format!("{}: No such file or directory", path.as_ref().display())
366+
get_message_with_args(
367+
"df-error-no-such-file-or-directory",
368+
HashMap::from([("path".to_string(), path.as_ref().display().to_string())])
369+
)
363370
));
364371
}
365372
Err(FsError::MountMissing) => {
366-
show!(USimpleError::new(1, "no file systems processed"));
373+
show!(USimpleError::new(
374+
1,
375+
get_message("df-error-no-file-systems-processed")
376+
));
367377
}
368378
#[cfg(not(windows))]
369379
Err(FsError::OverMounted) => {
370380
show!(USimpleError::new(
371381
1,
372-
format!(
373-
"cannot access {}: over-mounted by another device",
374-
path.as_ref().quote()
382+
get_message_with_args(
383+
"df-error-cannot-access-over-mounted",
384+
HashMap::from([("path".to_string(), path.as_ref().quote().to_string())])
375385
)
376386
));
377387
}
378388
}
379389
}
380390
if get_exit_code() == 0 && result.is_empty() {
381-
show!(USimpleError::new(1, "no file systems processed"));
391+
show!(USimpleError::new(
392+
1,
393+
get_message("df-error-no-file-systems-processed")
394+
));
382395
return Ok(result);
383396
}
384397

@@ -405,7 +418,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
405418
#[cfg(windows)]
406419
{
407420
if matches.get_flag(OPT_INODES) {
408-
println!("{}: doesn't support -i option", uucore::util_name());
421+
println!(
422+
"{}",
423+
get_message_with_args(
424+
"df-error-inodes-not-supported-windows",
425+
HashMap::from([("program".to_string(), uucore::util_name().to_string())])
426+
)
427+
);
409428
return Ok(());
410429
}
411430
}
@@ -415,20 +434,23 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
415434
let filesystems: Vec<Filesystem> = match matches.get_many::<String>(OPT_PATHS) {
416435
None => {
417436
let filesystems = get_all_filesystems(&opt).map_err(|e| {
418-
let context = "cannot read table of mounted file systems";
437+
let context = get_message("df-error-cannot-read-table-of-mounted-filesystems");
419438
USimpleError::new(e.code(), format!("{context}: {e}"))
420439
})?;
421440

422441
if filesystems.is_empty() {
423-
return Err(USimpleError::new(1, "no file systems processed"));
442+
return Err(USimpleError::new(
443+
1,
444+
get_message("df-error-no-file-systems-processed"),
445+
));
424446
}
425447

426448
filesystems
427449
}
428450
Some(paths) => {
429451
let paths: Vec<_> = paths.collect();
430452
let filesystems = get_named_filesystems(&paths, &opt).map_err(|e| {
431-
let context = "cannot read table of mounted file systems";
453+
let context = get_message("df-error-cannot-read-table-of-mounted-filesystems");
432454
USimpleError::new(e.code(), format!("{context}: {e}"))
433455
})?;
434456

@@ -458,15 +480,15 @@ pub fn uu_app() -> Command {
458480
.arg(
459481
Arg::new(OPT_HELP)
460482
.long(OPT_HELP)
461-
.help("Print help information.")
483+
.help(get_message("df-help-print-help"))
462484
.action(ArgAction::Help),
463485
)
464486
.arg(
465487
Arg::new(OPT_ALL)
466488
.short('a')
467489
.long("all")
468490
.overrides_with(OPT_ALL)
469-
.help("include dummy file systems")
491+
.help(get_message("df-help-all"))
470492
.action(ArgAction::SetTrue),
471493
)
472494
.arg(
@@ -475,46 +497,43 @@ pub fn uu_app() -> Command {
475497
.long("block-size")
476498
.value_name("SIZE")
477499
.overrides_with_all([OPT_KILO, OPT_BLOCKSIZE])
478-
.help(
479-
"scale sizes by SIZE before printing them; e.g.\
480-
'-BM' prints sizes in units of 1,048,576 bytes",
481-
),
500+
.help(get_message("df-help-block-size")),
482501
)
483502
.arg(
484503
Arg::new(OPT_TOTAL)
485504
.long("total")
486505
.overrides_with(OPT_TOTAL)
487-
.help("produce a grand total")
506+
.help(get_message("df-help-total"))
488507
.action(ArgAction::SetTrue),
489508
)
490509
.arg(
491510
Arg::new(OPT_HUMAN_READABLE_BINARY)
492511
.short('h')
493512
.long("human-readable")
494513
.overrides_with_all([OPT_HUMAN_READABLE_DECIMAL, OPT_HUMAN_READABLE_BINARY])
495-
.help("print sizes in human readable format (e.g., 1K 234M 2G)")
514+
.help(get_message("df-help-human-readable"))
496515
.action(ArgAction::SetTrue),
497516
)
498517
.arg(
499518
Arg::new(OPT_HUMAN_READABLE_DECIMAL)
500519
.short('H')
501520
.long("si")
502521
.overrides_with_all([OPT_HUMAN_READABLE_BINARY, OPT_HUMAN_READABLE_DECIMAL])
503-
.help("likewise, but use powers of 1000 not 1024")
522+
.help(get_message("df-help-si"))
504523
.action(ArgAction::SetTrue),
505524
)
506525
.arg(
507526
Arg::new(OPT_INODES)
508527
.short('i')
509528
.long("inodes")
510529
.overrides_with(OPT_INODES)
511-
.help("list inode information instead of block usage")
530+
.help(get_message("df-help-inodes"))
512531
.action(ArgAction::SetTrue),
513532
)
514533
.arg(
515534
Arg::new(OPT_KILO)
516535
.short('k')
517-
.help("like --block-size=1K")
536+
.help(get_message("df-help-kilo"))
518537
.overrides_with_all([OPT_BLOCKSIZE, OPT_KILO])
519538
.action(ArgAction::SetTrue),
520539
)
@@ -523,14 +542,14 @@ pub fn uu_app() -> Command {
523542
.short('l')
524543
.long("local")
525544
.overrides_with(OPT_LOCAL)
526-
.help("limit listing to local file systems")
545+
.help(get_message("df-help-local"))
527546
.action(ArgAction::SetTrue),
528547
)
529548
.arg(
530549
Arg::new(OPT_NO_SYNC)
531550
.long("no-sync")
532551
.overrides_with_all([OPT_SYNC, OPT_NO_SYNC])
533-
.help("do not invoke sync before getting usage info (default)")
552+
.help(get_message("df-help-no-sync"))
534553
.action(ArgAction::SetTrue),
535554
)
536555
.arg(
@@ -545,24 +564,21 @@ pub fn uu_app() -> Command {
545564
.default_missing_values(OUTPUT_FIELD_LIST)
546565
.default_values(["source", "size", "used", "avail", "pcent", "target"])
547566
.conflicts_with_all([OPT_INODES, OPT_PORTABILITY, OPT_PRINT_TYPE])
548-
.help(
549-
"use the output format defined by FIELD_LIST, \
550-
or print all fields if FIELD_LIST is omitted.",
551-
),
567+
.help(get_message("df-help-output")),
552568
)
553569
.arg(
554570
Arg::new(OPT_PORTABILITY)
555571
.short('P')
556572
.long("portability")
557573
.overrides_with(OPT_PORTABILITY)
558-
.help("use the POSIX output format")
574+
.help(get_message("df-help-portability"))
559575
.action(ArgAction::SetTrue),
560576
)
561577
.arg(
562578
Arg::new(OPT_SYNC)
563579
.long("sync")
564580
.overrides_with_all([OPT_NO_SYNC, OPT_SYNC])
565-
.help("invoke sync before getting usage info (non-windows only)")
581+
.help(get_message("df-help-sync"))
566582
.action(ArgAction::SetTrue),
567583
)
568584
.arg(
@@ -572,14 +588,14 @@ pub fn uu_app() -> Command {
572588
.value_parser(ValueParser::os_string())
573589
.value_name("TYPE")
574590
.action(ArgAction::Append)
575-
.help("limit listing to file systems of type TYPE"),
591+
.help(get_message("df-help-type")),
576592
)
577593
.arg(
578594
Arg::new(OPT_PRINT_TYPE)
579595
.short('T')
580596
.long("print-type")
581597
.overrides_with(OPT_PRINT_TYPE)
582-
.help("print file system type")
598+
.help(get_message("df-help-print-type"))
583599
.action(ArgAction::SetTrue),
584600
)
585601
.arg(
@@ -590,7 +606,7 @@ pub fn uu_app() -> Command {
590606
.value_parser(ValueParser::os_string())
591607
.value_name("TYPE")
592608
.use_value_delimiter(true)
593-
.help("limit listing to file systems not of type TYPE"),
609+
.help(get_message("df-help-exclude-type")),
594610
)
595611
.arg(
596612
Arg::new(OPT_PATHS)

0 commit comments

Comments
 (0)