From 90e91dd43dab67a340ae3d50dabeab5b19ed2e32 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Mon, 9 Jun 2025 09:48:26 +0200 Subject: [PATCH] test: also translate errors.rs --- src/uu/test/locales/en-US.ftl | 7 +++++++ src/uu/test/locales/fr-FR.ftl | 7 +++++++ src/uu/test/src/error.rs | 16 +++++++++------- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/uu/test/locales/en-US.ftl b/src/uu/test/locales/en-US.ftl index bcb1bc486..86871637f 100644 --- a/src/uu/test/locales/en-US.ftl +++ b/src/uu/test/locales/en-US.ftl @@ -70,3 +70,10 @@ test-after-help = Exit with the status determined by EXPRESSION. # Error messages test-error-missing-closing-bracket = missing '{"]"}' +test-error-expected = expected { $value } +test-error-expected-value = expected value +test-error-missing-argument = missing argument after { $argument } +test-error-extra-argument = extra argument { $argument } +test-error-unknown-operator = unknown operator { $operator } +test-error-invalid-integer = invalid integer { $value } +test-error-unary-operator-expected = { $operator }: unary operator expected diff --git a/src/uu/test/locales/fr-FR.ftl b/src/uu/test/locales/fr-FR.ftl index 0c0ccf28e..78cae9b44 100644 --- a/src/uu/test/locales/fr-FR.ftl +++ b/src/uu/test/locales/fr-FR.ftl @@ -70,3 +70,10 @@ test-after-help = Quitter avec le statut déterminé par EXPRESSION. # Messages d'erreur test-error-missing-closing-bracket = '{"]"}' manquant +test-error-expected = { $value } attendu +test-error-expected-value = valeur attendue +test-error-missing-argument = argument manquant après { $argument } +test-error-extra-argument = argument supplémentaire { $argument } +test-error-unknown-operator = opérateur inconnu { $operator } +test-error-invalid-integer = entier invalide { $value } +test-error-unary-operator-expected = { $operator } : opérateur unaire attendu diff --git a/src/uu/test/src/error.rs b/src/uu/test/src/error.rs index 235786bc6..fd66641a9 100644 --- a/src/uu/test/src/error.rs +++ b/src/uu/test/src/error.rs @@ -3,24 +3,26 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +use std::collections::HashMap; use thiserror::Error; +use uucore::locale::{get_message, get_message_with_args}; /// Represents an error encountered while parsing a test expression #[derive(Error, Debug)] pub enum ParseError { - #[error("expected value")] + #[error("{}", get_message("test-error-expected-value"))] ExpectedValue, - #[error("expected {0}")] + #[error("{}", get_message_with_args("test-error-expected", HashMap::from([("value".to_string(), .0.to_string())])))] Expected(String), - #[error("extra argument {0}")] + #[error("{}", get_message_with_args("test-error-extra-argument", HashMap::from([("argument".to_string(), .0.to_string())])))] ExtraArgument(String), - #[error("missing argument after {0}")] + #[error("{}", get_message_with_args("test-error-missing-argument", HashMap::from([("argument".to_string(), .0.to_string())])))] MissingArgument(String), - #[error("unknown operator {0}")] + #[error("{}", get_message_with_args("test-error-unknown-operator", HashMap::from([("operator".to_string(), .0.to_string())])))] UnknownOperator(String), - #[error("invalid integer {0}")] + #[error("{}", get_message_with_args("test-error-invalid-integer", HashMap::from([("value".to_string(), .0.to_string())])))] InvalidInteger(String), - #[error("{0}: unary operator expected")] + #[error("{}", get_message_with_args("test-error-unary-operator-expected", HashMap::from([("operator".to_string(), .0.to_string())])))] UnaryOperatorExpected(String), }