Skip to content

Commit fdb1a2c

Browse files
committed
l10n: port seq for translation + add french
1 parent f825409 commit fdb1a2c

File tree

4 files changed

+52
-11
lines changed

4 files changed

+52
-11
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,19 @@ seq-about = Display numbers from FIRST to LAST, in steps of INCREMENT.
22
seq-usage = seq [OPTION]... LAST
33
seq [OPTION]... FIRST LAST
44
seq [OPTION]... FIRST INCREMENT LAST
5+
6+
# Help messages
7+
seq-help-separator = Separator character (defaults to \n)
8+
seq-help-terminator = Terminator character (defaults to \n)
9+
seq-help-equal-width = Equalize widths of all numbers by padding with zeros
10+
seq-help-format = use printf style floating-point FORMAT
11+
12+
# Error messages
13+
seq-error-parse = invalid { $type } argument: { $arg }
14+
seq-error-zero-increment = invalid Zero increment value: { $arg }
15+
seq-error-no-arguments = missing operand
16+
seq-error-format-and-equal-width = format string may not be specified when printing equal width strings
17+
18+
# Parse error types
19+
seq-parse-error-type-float = floating point
20+
seq-parse-error-type-nan = 'not-a-number'

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
seq-about = Afficher les nombres de PREMIER à DERNIER, par incréments d'INCRÉMENT.
2+
seq-usage = seq [OPTION]... DERNIER
3+
seq [OPTION]... PREMIER DERNIER
4+
seq [OPTION]... PREMIER INCRÉMENT DERNIER
5+
6+
# Messages d'aide
7+
seq-help-separator = Caractère séparateur (par défaut \n)
8+
seq-help-terminator = Caractère terminateur (par défaut \n)
9+
seq-help-equal-width = Égaliser les largeurs de tous les nombres en remplissant avec des zéros
10+
seq-help-format = utiliser le FORMAT de nombre à virgule flottante de style printf
11+
12+
# Messages d'erreur
13+
seq-error-parse = argument { $type } invalide : { $arg }
14+
seq-error-zero-increment = valeur d'incrément zéro invalide : { $arg }
15+
seq-error-no-arguments = opérande manquant
16+
seq-error-format-and-equal-width = la chaîne de format ne peut pas être spécifiée lors de l'impression de chaînes de largeur égale
17+
18+
# Types d'erreur d'analyse
19+
seq-parse-error-type-float = nombre à virgule flottante
20+
seq-parse-error-type-nan = 'non-un-nombre'

src/uu/seq/src/error.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,44 @@
55
// spell-checker:ignore numberparse
66
//! Errors returned by seq.
77
use crate::numberparse::ParseNumberError;
8+
use std::collections::HashMap;
89
use thiserror::Error;
910
use uucore::display::Quotable;
1011
use uucore::error::UError;
12+
use uucore::locale::{get_message, get_message_with_args};
1113

1214
#[derive(Debug, Error)]
1315
pub enum SeqError {
1416
/// An error parsing the input arguments.
1517
///
1618
/// The parameters are the [`String`] argument as read from the
1719
/// command line and the underlying parsing error itself.
18-
#[error("invalid {} argument: {}", parse_error_type(.1), .0.quote())]
20+
#[error("{}", get_message_with_args("seq-error-parse", HashMap::from([("type".to_string(), parse_error_type(.1).to_string()), ("arg".to_string(), .0.quote().to_string())])))]
1921
ParseError(String, ParseNumberError),
2022

2123
/// The increment argument was zero, which is not allowed.
2224
///
2325
/// The parameter is the increment argument as a [`String`] as read
2426
/// from the command line.
25-
#[error("invalid Zero increment value: {}", .0.quote())]
27+
#[error("{}", get_message_with_args("seq-error-zero-increment", HashMap::from([("arg".to_string(), .0.quote().to_string())])))]
2628
ZeroIncrement(String),
2729

2830
/// No arguments were passed to this function, 1 or more is required
29-
#[error("missing operand")]
31+
#[error("{}", get_message_with_args("seq-error-no-arguments", HashMap::new()))]
3032
NoArguments,
3133

3234
/// Both a format and equal width where passed to seq
33-
#[error("format string may not be specified when printing equal width strings")]
35+
#[error(
36+
"{}",
37+
get_message_with_args("seq-error-format-and-equal-width", HashMap::new())
38+
)]
3439
FormatAndEqualWidth,
3540
}
3641

37-
fn parse_error_type(e: &ParseNumberError) -> &'static str {
42+
fn parse_error_type(e: &ParseNumberError) -> String {
3843
match e {
39-
ParseNumberError::Float => "floating point",
40-
ParseNumberError::Nan => "'not-a-number'",
44+
ParseNumberError::Float => get_message("seq-parse-error-type-float"),
45+
ParseNumberError::Nan => get_message("seq-parse-error-type-nan"),
4146
}
4247
}
4348

src/uu/seq/src/seq.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,26 +227,26 @@ pub fn uu_app() -> Command {
227227
Arg::new(OPT_SEPARATOR)
228228
.short('s')
229229
.long("separator")
230-
.help("Separator character (defaults to \\n)"),
230+
.help(get_message("seq-help-separator")),
231231
)
232232
.arg(
233233
Arg::new(OPT_TERMINATOR)
234234
.short('t')
235235
.long("terminator")
236-
.help("Terminator character (defaults to \\n)"),
236+
.help(get_message("seq-help-terminator")),
237237
)
238238
.arg(
239239
Arg::new(OPT_EQUAL_WIDTH)
240240
.short('w')
241241
.long("equal-width")
242-
.help("Equalize widths of all numbers by padding with zeros")
242+
.help(get_message("seq-help-equal-width"))
243243
.action(ArgAction::SetTrue),
244244
)
245245
.arg(
246246
Arg::new(OPT_FORMAT)
247247
.short('f')
248248
.long(OPT_FORMAT)
249-
.help("use printf style floating-point FORMAT"),
249+
.help(get_message("seq-help-format")),
250250
)
251251
.arg(
252252
// we use allow_hyphen_values instead of allow_negative_numbers because clap removed

0 commit comments

Comments
 (0)