Skip to content

Commit 143adfa

Browse files
authored
Merge pull request #8141 from sylvestre/l10n-dircolors
l10n: port dircolors for translation + add french
2 parents ad7c6ea + ff184c8 commit 143adfa

File tree

3 files changed

+71
-20
lines changed

3 files changed

+71
-20
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,21 @@ dircolors-usage = dircolors [OPTION]... [FILE]
33
dircolors-after-help = If FILE is specified, read it to determine which colors to use for which
44
file types and extensions. Otherwise, a precompiled database is used.
55
For details on the format of these files, run 'dircolors --print-database'
6+
7+
# Help messages
8+
dircolors-help-bourne-shell = output Bourne shell code to set LS_COLORS
9+
dircolors-help-c-shell = output C shell code to set LS_COLORS
10+
dircolors-help-print-database = print the byte counts
11+
dircolors-help-print-ls-colors = output fully escaped colors for display
12+
13+
# Error messages
14+
dircolors-error-shell-and-output-exclusive = the options to output non shell syntax,
15+
and to select a shell syntax are mutually exclusive
16+
dircolors-error-print-database-and-ls-colors-exclusive = options --print-database and --print-ls-colors are mutually exclusive
17+
dircolors-error-extra-operand-print-database = extra operand { $operand }
18+
file operands cannot be combined with --print-database (-p)
19+
dircolors-error-no-shell-environment = no SHELL environment variable, and no shell type option given
20+
dircolors-error-extra-operand = extra operand { $operand }
21+
dircolors-error-expected-file-got-directory = expected file, got directory { $path }
22+
dircolors-error-invalid-line-missing-token = { $file }:{ $line }: invalid line; missing second token
23+
dircolors-error-unrecognized-keyword = unrecognized keyword { $keyword }

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
dircolors-about = Afficher les commandes pour définir la variable d'environnement LS_COLORS.
2+
dircolors-usage = dircolors [OPTION]... [FICHIER]
3+
dircolors-after-help = Si FICHIER est spécifié, le lire pour déterminer quelles couleurs utiliser pour quels
4+
types de fichiers et extensions. Sinon, une base de données précompilée est utilisée.
5+
Pour les détails sur le format de ces fichiers, exécutez 'dircolors --print-database'
6+
7+
# Messages d'aide
8+
dircolors-help-bourne-shell = afficher le code Bourne shell pour définir LS_COLORS
9+
dircolors-help-c-shell = afficher le code C shell pour définir LS_COLORS
10+
dircolors-help-print-database = afficher la base de données de configuration
11+
dircolors-help-print-ls-colors = afficher les couleurs entièrement échappées pour l'affichage
12+
13+
# Messages d'erreur
14+
dircolors-error-shell-and-output-exclusive = les options pour afficher une syntaxe non-shell
15+
et pour sélectionner une syntaxe shell sont mutuellement exclusives
16+
dircolors-error-print-database-and-ls-colors-exclusive = les options --print-database et --print-ls-colors sont mutuellement exclusives
17+
dircolors-error-extra-operand-print-database = opérande supplémentaire { $operand }
18+
les opérandes de fichier ne peuvent pas être combinées avec --print-database (-p)
19+
dircolors-error-no-shell-environment = aucune variable d'environnement SHELL, et aucune option de type de shell donnée
20+
dircolors-error-extra-operand = opérande supplémentaire { $operand }
21+
dircolors-error-expected-file-got-directory = fichier attendu, répertoire obtenu { $path }
22+
dircolors-error-invalid-line-missing-token = { $file }:{ $line } : ligne invalide ; jeton manquant
23+
dircolors-error-unrecognized-keyword = mot-clé non reconnu { $keyword }

src/uu/dircolors/src/dircolors.rs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// spell-checker:ignore (ToDO) clrtoeol dircolors eightbit endcode fnmatch leftcode multihardlink rightcode setenv sgid suid colorterm disp
77

88
use std::borrow::Borrow;
9+
use std::collections::HashMap;
910
use std::env;
1011
use std::fmt::Write as _;
1112
use std::fs::File;
@@ -16,7 +17,7 @@ use clap::{Arg, ArgAction, Command};
1617
use uucore::colors::{FILE_ATTRIBUTE_CODES, FILE_COLORS, FILE_TYPES, TERMS};
1718
use uucore::display::Quotable;
1819
use uucore::error::{UResult, USimpleError, UUsageError};
19-
use uucore::locale::get_message;
20+
use uucore::locale::{get_message, get_message_with_args};
2021
use uucore::{format_usage, parser::parse_glob};
2122

2223
mod options {
@@ -132,26 +133,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
132133
{
133134
return Err(UUsageError::new(
134135
1,
135-
"the options to output non shell syntax,\n\
136-
and to select a shell syntax are mutually exclusive",
136+
get_message("dircolors-error-shell-and-output-exclusive"),
137137
));
138138
}
139139

140140
if matches.get_flag(options::PRINT_DATABASE) && matches.get_flag(options::PRINT_LS_COLORS) {
141141
return Err(UUsageError::new(
142142
1,
143-
"options --print-database and --print-ls-colors are mutually exclusive",
143+
get_message("dircolors-error-print-database-and-ls-colors-exclusive"),
144144
));
145145
}
146146

147147
if matches.get_flag(options::PRINT_DATABASE) {
148148
if !files.is_empty() {
149149
return Err(UUsageError::new(
150150
1,
151-
format!(
152-
"extra operand {}\nfile operands cannot be combined with \
153-
--print-database (-p)",
154-
files[0].quote()
151+
get_message_with_args(
152+
"dircolors-error-extra-operand-print-database",
153+
HashMap::from([("operand".to_string(), files[0].quote().to_string())]),
155154
),
156155
));
157156
}
@@ -175,7 +174,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
175174
OutputFmt::Unknown => {
176175
return Err(USimpleError::new(
177176
1,
178-
"no SHELL environment variable, and no shell type option given",
177+
get_message("dircolors-error-no-shell-environment"),
179178
));
180179
}
181180
fmt => out_format = fmt,
@@ -201,7 +200,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
201200
} else if files.len() > 1 {
202201
return Err(UUsageError::new(
203202
1,
204-
format!("extra operand {}", files[1].quote()),
203+
get_message_with_args(
204+
"dircolors-error-extra-operand",
205+
HashMap::from([("operand".to_string(), files[1].quote().to_string())]),
206+
),
205207
));
206208
} else if files[0].eq("-") {
207209
let fin = BufReader::new(std::io::stdin());
@@ -212,7 +214,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
212214
if path.is_dir() {
213215
return Err(USimpleError::new(
214216
2,
215-
format!("expected file, got directory {}", path.quote()),
217+
get_message_with_args(
218+
"dircolors-error-expected-file-got-directory",
219+
HashMap::from([("path".to_string(), path.quote().to_string())]),
220+
),
216221
));
217222
}
218223
match File::open(path) {
@@ -253,7 +258,7 @@ pub fn uu_app() -> Command {
253258
.short('b')
254259
.visible_alias("bourne-shell")
255260
.overrides_with(options::C_SHELL)
256-
.help("output Bourne shell code to set LS_COLORS")
261+
.help(get_message("dircolors-help-bourne-shell"))
257262
.action(ArgAction::SetTrue),
258263
)
259264
.arg(
@@ -262,20 +267,20 @@ pub fn uu_app() -> Command {
262267
.short('c')
263268
.visible_alias("c-shell")
264269
.overrides_with(options::BOURNE_SHELL)
265-
.help("output C shell code to set LS_COLORS")
270+
.help(get_message("dircolors-help-c-shell"))
266271
.action(ArgAction::SetTrue),
267272
)
268273
.arg(
269274
Arg::new(options::PRINT_DATABASE)
270275
.long("print-database")
271276
.short('p')
272-
.help("print the byte counts")
277+
.help(get_message("dircolors-help-print-database"))
273278
.action(ArgAction::SetTrue),
274279
)
275280
.arg(
276281
Arg::new(options::PRINT_LS_COLORS)
277282
.long("print-ls-colors")
278-
.help("output fully escaped colors for display")
283+
.help(get_message("dircolors-help-print-ls-colors"))
279284
.action(ArgAction::SetTrue),
280285
)
281286
.arg(
@@ -375,10 +380,12 @@ where
375380

376381
let (key, val) = line.split_two();
377382
if val.is_empty() {
378-
return Err(format!(
379-
// The double space is what GNU is doing
380-
"{}:{num}: invalid line; missing second token",
381-
fp.maybe_quote(),
383+
return Err(get_message_with_args(
384+
"dircolors-error-invalid-line-missing-token",
385+
HashMap::from([
386+
("file".to_string(), fp.maybe_quote().to_string()),
387+
("line".to_string(), num.to_string()),
388+
]),
382389
));
383390
}
384391

@@ -461,7 +468,10 @@ fn append_entry(
461468
result.push_str(&disp);
462469
Ok(())
463470
} else {
464-
Err(format!("unrecognized keyword {key}"))
471+
Err(get_message_with_args(
472+
"dircolors-error-unrecognized-keyword",
473+
HashMap::from([("keyword".to_string(), key.to_string())]),
474+
))
465475
}
466476
}
467477
}

0 commit comments

Comments
 (0)