diff --git a/src/uu/seq/locales/en-US.ftl b/src/uu/seq/locales/en-US.ftl index 818ebc86c..34a97d438 100644 --- a/src/uu/seq/locales/en-US.ftl +++ b/src/uu/seq/locales/en-US.ftl @@ -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' diff --git a/src/uu/seq/locales/fr-FR.ftl b/src/uu/seq/locales/fr-FR.ftl new file mode 100644 index 000000000..ed8049820 --- /dev/null +++ b/src/uu/seq/locales/fr-FR.ftl @@ -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' diff --git a/src/uu/seq/src/error.rs b/src/uu/seq/src/error.rs index 819368aad..cebd49fe8 100644 --- a/src/uu/seq/src/error.rs +++ b/src/uu/seq/src/error.rs @@ -5,9 +5,11 @@ // 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 { @@ -15,29 +17,32 @@ pub enum SeqError { /// /// 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"), } } diff --git a/src/uu/seq/src/seq.rs b/src/uu/seq/src/seq.rs index 2dd5f17b8..db573c4d4 100644 --- a/src/uu/seq/src/seq.rs +++ b/src/uu/seq/src/seq.rs @@ -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