1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

test: also translate errors.rs

This commit is contained in:
Sylvestre Ledru 2025-06-09 09:48:26 +02:00
parent 09bb35e11e
commit 90e91dd43d
3 changed files with 23 additions and 7 deletions

View file

@ -70,3 +70,10 @@ test-after-help = Exit with the status determined by EXPRESSION.
# Error messages # Error messages
test-error-missing-closing-bracket = missing '{"]"}' 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

View file

@ -70,3 +70,10 @@ test-after-help = Quitter avec le statut déterminé par EXPRESSION.
# Messages d'erreur # Messages d'erreur
test-error-missing-closing-bracket = '{"]"}' manquant 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

View file

@ -3,24 +3,26 @@
// For the full copyright and license information, please view the LICENSE // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use std::collections::HashMap;
use thiserror::Error; use thiserror::Error;
use uucore::locale::{get_message, get_message_with_args};
/// Represents an error encountered while parsing a test expression /// Represents an error encountered while parsing a test expression
#[derive(Error, Debug)] #[derive(Error, Debug)]
pub enum ParseError { pub enum ParseError {
#[error("expected value")] #[error("{}", get_message("test-error-expected-value"))]
ExpectedValue, ExpectedValue,
#[error("expected {0}")] #[error("{}", get_message_with_args("test-error-expected", HashMap::from([("value".to_string(), .0.to_string())])))]
Expected(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), 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), 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), 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), 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), UnaryOperatorExpected(String),
} }