Skip to content

Commit e61c525

Browse files
committed
l10n: port unexpand to translation + add french
1 parent a769fc7 commit e61c525

3 files changed

Lines changed: 43 additions & 13 deletions

File tree

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
11
unexpand-about = Convert blanks in each FILE to tabs, writing to standard output.
22
With no FILE, or when FILE is -, read standard input.
33
unexpand-usage = unexpand [OPTION]... [FILE]...
4+
5+
# Help messages
6+
unexpand-help-all = convert all blanks, instead of just initial blanks
7+
unexpand-help-first-only = convert only leading sequences of blanks (overrides -a)
8+
unexpand-help-tabs = use comma separated LIST of tab positions or have tabs N characters apart instead of 8 (enables -a)
9+
unexpand-help-no-utf8 = interpret input file as 8-bit ASCII rather than UTF-8
10+
11+
# Error messages
12+
unexpand-error-invalid-character = tab size contains invalid character(s): { $char }
13+
unexpand-error-tab-size-cannot-be-zero = tab size cannot be 0
14+
unexpand-error-tab-size-too-large = tab stop value is too large
15+
unexpand-error-tab-sizes-must-be-ascending = tab sizes must be ascending
16+
unexpand-error-is-directory = { $path }: Is a directory

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
unexpand-about = Convertir les espaces dans chaque FICHIER en tabulations, en écrivant vers la sortie standard.
2+
Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard.
3+
unexpand-usage = unexpand [OPTION]... [FICHIER]...
4+
5+
# Messages d'aide
6+
unexpand-help-all = convertir tous les espaces, au lieu de seulement les espaces initiaux
7+
unexpand-help-first-only = convertir seulement les séquences d'espaces en début de ligne (remplace -a)
8+
unexpand-help-tabs = utiliser une LISTE séparée par des virgules de positions de tabulations ou avoir des tabulations de N caractères au lieu de 8 (active -a)
9+
unexpand-help-no-utf8 = interpréter le fichier d'entrée comme ASCII 8-bit plutôt que UTF-8
10+
11+
# Messages d'erreur
12+
unexpand-error-invalid-character = la taille de tabulation contient des caractères invalides : { $char }
13+
unexpand-error-tab-size-cannot-be-zero = la taille de tabulation ne peut pas être 0
14+
unexpand-error-tab-size-too-large = la valeur d'arrêt de tabulation est trop grande
15+
unexpand-error-tab-sizes-must-be-ascending = les tailles de tabulation doivent être croissantes
16+
unexpand-error-is-directory = { $path } : Est un répertoire

src/uu/unexpand/src/unexpand.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// spell-checker:ignore (ToDO) nums aflag uflag scol prevtab amode ctype cwidth nbytes lastcol pctype Preprocess
77

88
use clap::{Arg, ArgAction, Command};
9+
use std::collections::HashMap;
910
use std::fs::File;
1011
use std::io::{BufRead, BufReader, BufWriter, Read, Stdout, Write, stdin, stdout};
1112
use std::num::IntErrorKind;
@@ -17,19 +18,19 @@ use uucore::display::Quotable;
1718
use uucore::error::{FromIo, UError, UResult, USimpleError};
1819
use uucore::{format_usage, show};
1920

20-
use uucore::locale::get_message;
21+
use uucore::locale::{get_message, get_message_with_args};
2122

2223
const DEFAULT_TABSTOP: usize = 8;
2324

2425
#[derive(Debug, Error)]
2526
enum ParseError {
26-
#[error("tab size contains invalid character(s): {}", _0.quote())]
27+
#[error("{}", get_message_with_args("unexpand-error-invalid-character", HashMap::from([("char".to_string(), _0.quote().to_string())])))]
2728
InvalidCharacter(String),
28-
#[error("tab size cannot be 0")]
29+
#[error("{}", get_message("unexpand-error-tab-size-cannot-be-zero"))]
2930
TabSizeCannotBeZero,
30-
#[error("tab stop value is too large")]
31+
#[error("{}", get_message("unexpand-error-tab-size-too-large"))]
3132
TabSizeTooLarge,
32-
#[error("tab sizes must be ascending")]
33+
#[error("{}", get_message("unexpand-error-tab-sizes-must-be-ascending"))]
3334
TabSizesMustBeAscending,
3435
}
3536

@@ -169,31 +170,28 @@ pub fn uu_app() -> Command {
169170
Arg::new(options::ALL)
170171
.short('a')
171172
.long(options::ALL)
172-
.help("convert all blanks, instead of just initial blanks")
173+
.help(get_message("unexpand-help-all"))
173174
.action(ArgAction::SetTrue),
174175
)
175176
.arg(
176177
Arg::new(options::FIRST_ONLY)
177178
.long(options::FIRST_ONLY)
178-
.help("convert only leading sequences of blanks (overrides -a)")
179+
.help(get_message("unexpand-help-first-only"))
179180
.action(ArgAction::SetTrue),
180181
)
181182
.arg(
182183
Arg::new(options::TABS)
183184
.short('t')
184185
.long(options::TABS)
185-
.help(
186-
"use comma separated LIST of tab positions or have tabs N characters \
187-
apart instead of 8 (enables -a)",
188-
)
186+
.help(get_message("unexpand-help-tabs"))
189187
.action(ArgAction::Append)
190188
.value_name("N, LIST"),
191189
)
192190
.arg(
193191
Arg::new(options::NO_UTF8)
194192
.short('U')
195193
.long(options::NO_UTF8)
196-
.help("interpret input file as 8-bit ASCII rather than UTF-8")
194+
.help(get_message("unexpand-help-no-utf8"))
197195
.action(ArgAction::SetTrue),
198196
)
199197
}
@@ -204,7 +202,10 @@ fn open(path: &str) -> UResult<BufReader<Box<dyn Read + 'static>>> {
204202
if filename.is_dir() {
205203
Err(Box::new(USimpleError {
206204
code: 1,
207-
message: format!("{}: Is a directory", filename.display()),
205+
message: get_message_with_args(
206+
"unexpand-error-is-directory",
207+
HashMap::from([("path".to_string(), filename.display().to_string())]),
208+
),
208209
}))
209210
} else if path == "-" {
210211
Ok(BufReader::new(Box::new(stdin()) as Box<dyn Read>))

0 commit comments

Comments
 (0)