8000 l10n: port od for translation + add french · uutils/coreutils@989b653 · GitHub
[go: up one dir, main page]

Skip to content

Commit 989b653

Browse files
committed
l10n: port od for translation + add french
1 parent 05eb7ee commit 989b653

File tree

6 files changed

+222
-53
lines changed

6 files changed

+222
-53
lines changed

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,40 @@ od-after-help = Displays data in various human-readable formats. If multiple for
3939
4040
If an error occurred, a diagnostic message will be printed to stderr, and the
4141
exit code will be non-zero.
42+
43+
# Error messages
44+
od-error-invalid-endian = Invalid argument --endian={$endian}
45+
od-error-invalid-inputs = Invalid inputs: {$msg}
46+
od-error-too-large = value is too large
47+
od-error-radix-invalid = Radix must be one of [o, d, x, n], got: {$radix}
48+
od-error-radix-empty = Radix cannot be empty, and must be one of [o, d, x, n]
49+
od-error-invalid-width = invalid width {$width}; using {$min} instead
50+
od-error-missing-format-spec = missing format specification after '--format' / '-t'
51+
od-error-unexpected-char = unexpected char '{$char}' in format specification {$spec}
52+
od-error-invalid-number = invalid number {$number} in format specification {$spec}
53+
od-error-invalid-size = invalid size '{$size}' in format specification {$spec}
< 57AE code>54+
od-error-invalid-offset = invalid offset: {$offset}
55+
od-error-invalid-label = invalid label: {$label}
56+
od-error-too-many-inputs = too many inputs after --traditional: {$input}
57+
od-error-parse-failed = parse failed
58+
od-error-invalid-suffix = invalid suffix in --{$option} argument {$value}
59+
od-error-invalid-argument = invalid --{$option} argument {$value}
60+
od-error-argument-too-large = --{$option} argument {$value} too large
61+
od-error-skip-past-end = tried to skip past end of input
62+
63+
# Help messages
64+
od-help-help = Print help information.
65+
od-help-address-radix = Select the base in which file offsets are printed.
66+
od-help-skip-bytes = Skip bytes input bytes before formatting and writing.
67+
od-help-read-bytes = limit dump to BYTES input bytes
68+
od-help-endian = byte order to use for multi-byte formats
69+
od-help-a = named characters, ignoring high-order bit
70+
od-help-b = octal bytes
71+
od-help-c = ASCII characters or backslash escapes
72+
od-help-d = unsigned decimal 2-byte units
73+
od-help-D = unsigned decimal 4-byte units
74+
od-help-format = select output format or formats
75+
od-help-output-duplicates = do not use * to mark line suppression
76+
od-help-width = output BYTES bytes per output line. 32 is implied when BYTES is not
77+
specified.
78+
od-help-traditional = compatibility mode with one input, offset and label.

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

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
od-about = Afficher les fichiers en format octal et autres formats
2+
od-usage = od [OPTION]... [--] [NOMFICHIER]...
3+
od [-abcdDefFhHiIlLoOsxX] [NOMFICHIER] [[+][0x]DÉCALAGE[.][b]]
4+
od --traditional [OPTION]... [NOMFICHIER] [[+][0x]DÉCALAGE[.][b] [[+][0x]ÉTIQUETTE[.][b]]]
5+
od-after-help = Affiche les données dans divers formats lisibles par l'homme. Si plusieurs
6+
formats sont spécifiés, la sortie contiendra tous les formats dans l'ordre où ils
7+
apparaissent sur la ligne de commande. Chaque format sera imprimé sur une nouvelle
8+
ligne. Seule la ligne contenant le premier format sera préfixée avec le décalage.
9+
10+
Si aucun nom de fichier n'est spécifié, ou si c'est "-", stdin sera utilisé. Après
11+
un "--", aucune autre option ne sera reconnue. Cela permet d'avoir des noms de
12+
fichiers commençant par "-".
13+
14+
Si un nom de fichier est un nombre valide qui peut être utilisé comme décalage dans
15+
la deuxième forme, vous pouvez le forcer à être reconnu comme un nom de fichier si
16+
vous incluez une option comme "-j0", qui n'est valide que dans la première forme.
17+
18+
RADIX est l'un de o,d,x,n pour octal, décimal, hexadécimal ou aucun.
19+
20+
OCTETS est décimal par défaut, octal si préfixé par "0", ou hexadécimal si préfixé
21+
par "0x". Les suffixes b, KB, K, MB, M, GB, G multiplieront le nombre par 512,
22+
1000, 1024, 1000^2, 1024^2, 1000^3, 1024^3, 1000^2, 1024^2.
23+
24+
DÉCALAGE et ÉTIQUETTE sont octaux par défaut, hexadécimaux si préfixés par "0x" ou
25+
décimaux si un suffixe "." est ajouté. Le suffixe "b" multipliera par 512.
26+
27+
TYPE contient une ou plusieurs spécifications de format constituées de :
28+
a pour ASCII imprimable 7-bits
29+
c pour caractères utf-8 ou octal pour caractères non définis
30+
d[TAILLE] pour décimal signé
31+
f[TAILLE] pour virgule flottante
32+
o[TAILLE] pour octal
33+
u[TAILLE] pour décimal non signé
34+
x[TAILLE] pour hexadécimal
35+
TAILLE est le nombre d'octets qui peut être le nombre 1, 2, 4, 8 ou 16,
36+
ou C, I, S, L pour 1, 2, 4, 8 octets pour les types entiers,
37+
ou F, D, L pour 4, 8, 16 octets pour les virgules flottantes.
38+
Toute spécification de type peut avoir un suffixe "z", qui ajoutera un dump ASCII
39+
à la fin de la ligne.
40+
41+
Si une erreur s'est produite, un message de diagnostic sera imprimé sur stderr, et
42+
le code de sortie sera non-zéro.
43+
44+
# Messages d'erreur
45+
od-error-invalid-endian = Argument invalide --endian={$endian}
46+
od-error-invalid-inputs = Entrées invalides : {$msg}
47+
od-error-too-large = la valeur est trop grande
48+
od-error-radix-invalid = Radix doit être l'un de [o, d, x, n], reçu : {$radix}
49+
od-error-radix-empty = Radix ne peut pas être vide, et doit être l'un de [o, d, x, n]
50+
od-error-invalid-width = largeur invalide {$width} ; utilisation de {$min} à la place
51+
od-error-missing-format-spec = spécification de format manquante après '--format' / '-t'
52+
od-error-unexpected-char = caractère inattendu '{$char}' dans la spécification de format {$spec}
53+
od-error-invalid-number = nombre invalide {$number} dans la spécification de format {$spec}
54+
od-error-invalid-size = taille invalide '{$size}' dans la spécification de format {$spec}
55+
od-error-invalid-offset = décalage invalide : {$offset}
56+
od-error-invalid-label = étiquette invalide : {$label}
57+
od-error-too-many-inputs = trop d'entrées après --traditional : {$input}
58+
od-error-parse-failed = échec de l'analyse
59+
od-error-invalid-suffix = suffixe invalide dans l'argument --{$option} {$value}
60+
od-error-invalid-argument = argument --{$option} invalide {$value}
61+
od-error-argument-too-large = argument --{$option} {$value} trop grand
62+
od-error-skip-past-end = tentative d'ignorer au-delà de la fin de l'entrée
63+
64+
# Messages d'aide
65+
od-help-help = Afficher les informations d'aide.
66+
od-help-address-radix = Sélectionner la base dans laquelle les décalages de fichier sont imprimés.
67+
od-help-skip-bytes = Ignorer les octets d'entrée avant le formatage et l'écriture.
68+
od-help-read-bytes = limiter le dump à OCTETS octets d'entrée
69+
od-help-endian = ordre des octets à utiliser pour les formats multi-octets
70+
od-help-a = caractères nommés, ignorant le bit d'ordre supérieur
71+
od-help-b = octets octaux
72+
od-help-c = caractères ASCII ou échappements antislash
73+
od-help-d = unités décimales non signées 2-octets
74+
od-help-D = unités décimales non signées 4-octets
75+
od-help-format = sélectionner le(s) format(s) de sortie
76+
od-help-output-duplicates = ne pas utiliser * pour marquer la suppression de ligne
77+
od-help-width = sortir OCTETS octets par ligne de sortie. 32 est impliqué quand OCTETS n'est pas
78+
spécifié.
79+
od-help-traditional = mode de compatibilité avec une entrée, décalage et étiquette.

src/uu/od/src/od.rs

Lines changed: 65 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ mod prn_float;
2525
mod prn_int;
2626

2727
use std::cmp;
28+
use std::collections::HashMap;
2829
use std::fmt::Write;
2930
use std::io::BufReader;
3031

@@ -44,7 +45,7 @@ use clap::ArgAction;
4445
use clap::{Arg, ArgMatches, Command, parser::ValueSource};
4546
use uucore::display::Quotable;
4647
use uucore::error::{UResult, USimpleError};
47-
use uucore::locale::get_message;
48+
use uucore::locale::{get_message, get_message_with_args};
4849
use uucore::parser::parse_size::ParseSizeError;
4950
use uucore::parser::shortcut_value_parser::ShortcutValueParser;
5051
use uucore::{format_usage, show_error, show_warning};
@@ -86,7 +87,10 @@ impl OdOptions {
8687
_ => {
8788
return Err(USimpleError::new(
8889
1,
89-
format!("Invalid argument --endian={s}"),
90+
get_message_with_args(
91+
"od-error-invalid-endian",
92+
HashMap::from([("endian".to_string(), s.to_string())]),
93+
),
9094
));
9195
}
9296
}
@@ -109,8 +113,15 @@ impl OdOptions {
109113

110114
let mut label: Option<u64> = None;
111115

112-
let parsed_input = parse_inputs(matches)
113-
.map_err(|e| USimpleError::new(1, format!("Invalid inputs: {e}")))?;
116+
let parsed_input = parse_inputs(matches).map_err(|e| {
117+
USimpleError::new(
118+
1,
119+
get_message_with_args(
120+
"od-error-invalid-inputs",
121+
HashMap::from([("msg".to_string(), e.to_string())]),
122+
),
123+
)
124+
})?;
114125
let input_strings = match parsed_input {
115126
CommandLineInputs::FileNames(v) => v,
116127
CommandLineInputs::FileAndOffset((f, s, l)) => {
@@ -146,7 +157,16 @@ impl OdOptions {
146157
cmp::max(max, next.formatter_item_info.byte_size)
147158
});
148159
if line_bytes == 0 || line_bytes % min_bytes != 0 {
149-
show_warning!("invalid width {line_bytes}; using {min_bytes} instead");
160+
show_warning!(
161+
"{}",
162+
get_message_with_args(
163+
"od-error-invalid-width",
164+
HashMap::from([
165+
("width".to_string(), line_bytes.to_string()),
166+
("min".to_string(), min_bytes.to_string())
167+
])
168+
)
169+
);
150170
line_bytes = min_bytes;
151171
}
152172

@@ -183,16 +203,16 @@ impl OdOptions {
183203
_ => {
184204
return Err(USimpleError::new(
185205
1,
186-
"Radix must be one of [o, d, x, n]".to_string(),
206+
get_message_with_args(
207+
"od-error-radix-invalid",
208+
HashMap::from([("radix".to_string(), s.to_string())]),
209+
),
187210
));
188211
}
189212
}
190213
} else {
191214
// Return an error instead of panicking when `od -A ''` is executed.
192-
return Err(USimpleError::new(
193-
1,
194-
"Radix cannot be empty, and must be one of [o, d, x, n]".to_string(),
195-
));
215+
return Err(USimpleError::new(1, get_message("od-error-radix-empty")));
196216
}
197217
}
198218
};
@@ -261,34 +281,34 @@ pub fn uu_app() -> Command {
261281
.arg(
262282
Arg::new(options::HELP)
263283
.long(options::HELP)
264-
.help("Print help information.")
284+
.help(get_message("od-help-help"))
265285
.action(ArgAction::Help)
266286
)
267287
.arg(
268288
Arg::new(options::ADDRESS_RADIX)
269289
.short('A')
270290
.long(options::ADDRESS_RADIX)
271-
.help("Select the base in which file offsets are printed.")
291+
.help(get_message("od-help-address-radix"))
272292
.value_name("RADIX"),
273293
)
274294
.arg(
10000
275295
Arg::new(options::SKIP_BYTES)
276296
.short('j')
277297
.long(options::SKIP_BYTES)
278-
.help("Skip bytes input bytes before formatting and writing.")
298+
.help(get_message("od-help-skip-bytes"))
279299
.value_name("BYTES"),
280300
)
281301
.arg(
282302
Arg::new(options::READ_BYTES)
283303
.short('N')
284304
.long(options::READ_BYTES)
285-
.help("limit dump to BYTES input bytes")
305+
.help(get_message("od-help-read-bytes"))
286306
.value_name("BYTES"),
287307
)
288308
.arg(
289309
Arg::new(options::ENDIAN)
290310
.long(options::ENDIAN)
291-
.help("byte order to use for multi-byte formats")
311+
.help(get_message("od-help-endian"))
292312
.value_parser(ShortcutValueParser::new(["big", "little"]))
293313
.value_name("big|little"),
294314
)
@@ -306,31 +326,31 @@ pub fn uu_app() -> Command {
306326
.arg(
307327
Arg::new("a")
308328
.short('a')
309-
.help("named characters, ignoring high-order bit")
329+
.help(get_message("od-help-a"))
310330
.action(ArgAction::SetTrue),
311331
)
312332
.arg(
313333
Arg::new("b")
314334
.short('b')
315-
.help("octal bytes")
335+
.help(get_message("od-help-b"))
316336
.action(ArgAction::SetTrue),
317337
)
318338
.arg(
319339
Arg::new("c")
320340
.short('c')
321-
.help("ASCII characters or backslash escapes")
341+
.help(get_message("od-help-c"))
322342
.action(ArgAction::SetTrue),
323343
)
324344
.arg(
325345
Arg::new("d")
326346
.short('d')
327-
.help("unsigned decimal 2-byte units")
347+
.help(get_message("od-help-d"))
328348
.action(ArgAction::SetTrue),
329349
)
330350
.arg(
331351
Arg::new("D")
332352
.short('D')
333-
.help("unsigned decimal 4-byte units")
353+
.help(get_message("od-help-D"))
334354
.action(ArgAction::SetTrue),
335355
)
336356
.arg(
@@ -421,7 +441,7 @@ pub fn uu_app() -> Command {
421441
Arg::new(options::FORMAT)
422442
.short('t')
423443
.long("format")
424-
.help("select output format or formats")
444+
.help(get_message("od-help-format"))
425445
.action(ArgAction::Append)
426446
.num_args(1)
427447
.value_name("TYPE"),
@@ -430,25 +450,22 @@ pub fn uu_app() -> Command {
430450
Arg::new(options::OUTPUT_DUPLICATES)
431451
.short('v')
432452
.long(options::OUTPUT_DUPLICATES)
433-
.help("do not use * to mark line suppression")
453+
.help(get_message("od-help-output-duplicates"))
434454
.action(ArgAction::SetTrue),
435455
)
436456
.arg(
437457
Arg::new(options::WIDTH)
438458
.short('w')
439459
.long(options::WIDTH)
440-
.help(
441-
"output BYTES bytes per output line. 32 is implied when BYTES is not \
442-
specified.",
443-
)
460+
.help(get_message("od-help-width"))
444461
.default_missing_value("32")
445462
.value_name("BYTES")
446463
.num_args(..=1),
447464
)
448465
.arg(
449466
Arg::new(options::TRADITIONAL)
450467
.long(options::TRADITIONAL)
451-
.help("compatibility mode with one input, offset and label.")
468+
.help(get_message("od-help-traditional"))
452469
.action(ArgAction::SetTrue),
453470
)
454471
.arg(
@@ -631,12 +648,26 @@ fn format_error_message(error: &ParseSizeError, s: &str, option: &str) -> String
631648
// NOTE:
632649
// GNU's od echos affected flag, -N or --read-bytes (-j or --skip-bytes, etc.), depending user's selection
633650
match error {
634-
ParseSizeError::InvalidSuffix(_) => {
635-
format!("invalid suffix in --{option} argument {}", s.quote())
636-
}
637-
ParseSizeError::ParseFailure(_) | ParseSizeError::PhysicalMem(_) => {
638-
format!("invalid --{option} argument {}", s.quote())
639-
}
640-
ParseSizeError::SizeTooBig(_) => format!("--{option} argument {} too large", s.quote()),
651+
ParseSizeError::InvalidSuffix(_) => get_message_with_args(
652+
"od-error-invalid-suffix",
653+
HashMap::from([
654+
("option".to_string(), option.to_string()),
655+
("value".to_string(), s.quote().to_string()),
656+
]),
657+
),
658+
ParseSizeError::ParseFailure(_) | ParseSizeError::PhysicalMem(_) => get_message_with_args(
659+
"od-error-invalid-argument",
660+
HashMap::from([
661+
("option".to_string(), option.to_string()),
662+
("value".to_string(), s.quote().to_string()),
663+
]),
664+
),
665+
ParseSizeError::SizeTooBig(_) => get_message_with_args(
666+
"od-error-argument-too-large",
667+
HashMap::from([
668+
("option".to_string(), option.to_string()),
669+
("value".to_string(), s.quote().to_string()),
670+
]),
671+
),
641672
}
642673
}

0 commit comments

Comments
 (0)
0