Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/uu/seq/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,19 @@ seq-about = Display numbers from FIRST to LAST, in steps of INCREMENT.
seq-usage = seq [OPTION]... LAST
seq [OPTION]... FIRST LAST
seq [OPTION]... FIRST INCREMENT LAST

# Help messages
seq-help-separator = Separator character (defaults to \n)
seq-help-terminator = Terminator character (defaults to \n)
seq-help-equal-width = Equalize widths of all numbers by padding with zeros
seq-help-format = use printf style floating-point FORMAT

# Error messages
seq-error-parse = invalid { $type } argument: { $arg }
seq-error-zero-increment = invalid Zero increment value: { $arg }
seq-error-no-arguments = missing operand
seq-error-format-and-equal-width = format string may not be specified when printing equal width strings

# Parse error types
seq-parse-error-type-float = floating point
seq-parse-error-type-nan = 'not-a-number'
20 changes: 20 additions & 0 deletions src/uu/seq/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
seq-about = Afficher les nombres de PREMIER à DERNIER, par incréments d'INCRÉMENT.
seq-usage = seq [OPTION]... DERNIER
seq [OPTION]... PREMIER DERNIER
seq [OPTION]... PREMIER INCRÉMENT DERNIER

# Messages d'aide
seq-help-separator = Caractère séparateur (par défaut \n)
seq-help-terminator = Caractère terminateur (par défaut \n)
seq-help-equal-width = Égaliser les largeurs de tous les nombres en remplissant avec des zéros
seq-help-format = utiliser le FORMAT de nombre à virgule flottante de style printf

# Messages d'erreur
seq-error-parse = argument { $type } invalide : { $arg }
seq-error-zero-increment = valeur d'incrément zéro invalide : { $arg }
seq-error-no-arguments = opérande manquant
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

# Types d'erreur d'analyse
seq-parse-error-type-float = nombre à virgule flottante
seq-parse-error-type-nan = 'non-un-nombre'
19 changes: 12 additions & 7 deletions src/uu/seq/src/error.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the strings in parse_error_type should also be translated.

Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,44 @@
// spell-checker:ignore numberparse
//! Errors returned by seq.
use crate::numberparse::ParseNumberError;
use std::collections::HashMap;
use thiserror::Error;
use uucore::display::Quotable;
use uucore::error::UError;
use uucore::locale::{get_message, get_message_with_args};

#[derive(Debug, Error)]
pub enum SeqError {
/// An error parsing the input arguments.
///
/// The parameters are the [`String`] argument as read from the
/// command line and the underlying parsing error itself.
#[error("invalid {} argument: {}", parse_error_type(.1), .0.quote())]
#[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())])))]
ParseError(String, ParseNumberError),

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

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

/// Both a format and equal width where passed to seq
#[error("format string may not be specified when printing equal width strings")]
#[error(
"{}",
get_message_with_args("seq-error-format-and-equal-width", HashMap::new())
)]
FormatAndEqualWidth,
}

fn parse_error_type(e: &ParseNumberError) -> &'static str {
fn parse_error_type(e: &ParseNumberError) -> String {
match e {
ParseNumberError::Float => "floating point",
ParseNumberError::Nan => "'not-a-number'",
ParseNumberError::Float => get_message("seq-parse-error-type-float"),
ParseNumberError::Nan => get_message("seq-parse-error-type-nan"),
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/uu/seq/src/seq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,26 +227,26 @@ pub fn uu_app() -> Command {
Arg::new(OPT_SEPARATOR)
.short('s')
.long("separator")
.help("Separator character (defaults to \\n)"),
.help(get_message("seq-help-separator")),
)
.arg(
Arg::new(OPT_TERMINATOR)
.short('t')
.long("terminator")
.help("Terminator character (defaults to \\n)"),
.help(get_message("seq-help-terminator")),
)
.arg(
Arg::new(OPT_EQUAL_WIDTH)
.short('w')
.long("equal-width")
.help("Equalize widths of all numbers by padding with zeros")
.help(get_message("seq-help-equal-width"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(OPT_FORMAT)
.short('f')
.long(OPT_FORMAT)
.help("use printf style floating-point FORMAT"),
.help(get_message("seq-help-format")),
)
.arg(
// we use allow_hyphen_values instead of allow_negative_numbers because clap removed
Expand Down
Loading