From 39b51a8b9afa459e919f179877f7601047d72910 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Jun 2025 23:18:50 +0200 Subject: [PATCH] l10n: port tac for translation + add french --- src/uu/tac/locales/en-US.ftl | 10 ++++++++++ src/uu/tac/locales/fr-FR.ftl | 12 ++++++++++++ src/uu/tac/src/error.rs | 18 ++++++++---------- src/uu/tac/src/tac.rs | 6 +++--- 4 files changed, 33 insertions(+), 13 deletions(-) create mode 100644 src/uu/tac/locales/fr-FR.ftl diff --git a/src/uu/tac/locales/en-US.ftl b/src/uu/tac/locales/en-US.ftl index 28a3621f2..3c849c4d7 100644 --- a/src/uu/tac/locales/en-US.ftl +++ b/src/uu/tac/locales/en-US.ftl @@ -1,2 +1,12 @@ tac-about = Write each file to standard output, last line first. tac-usage = tac [OPTION]... [FILE]... +tac-help-before = attach the separator before instead of after +tac-help-regex = interpret the sequence as a regular expression +tac-help-separator = use STRING as the separator instead of newline + +# Error messages +tac-error-invalid-regex = invalid regular expression: { $error } +tac-error-invalid-argument = { $argument }: read error: Invalid argument +tac-error-file-not-found = failed to open { $filename } for reading: No such file or directory +tac-error-read-error = failed to read from { $filename }: { $error } +tac-error-write-error = failed to write to stdout: { $error } diff --git a/src/uu/tac/locales/fr-FR.ftl b/src/uu/tac/locales/fr-FR.ftl new file mode 100644 index 000000000..f49a39e8d --- /dev/null +++ b/src/uu/tac/locales/fr-FR.ftl @@ -0,0 +1,12 @@ +tac-about = Écrit chaque fichier sur la sortie standard, la dernière ligne en premier. +tac-usage = tac [OPTION]... [FICHIER]... +tac-help-before = attacher le séparateur avant plutôt qu'après +tac-help-regex = interpréter la séquence comme une expression régulière +tac-help-separator = utiliser CHAÎNE comme séparateur au lieu du saut de ligne + +# Messages d'erreur +tac-error-invalid-regex = expression régulière invalide : { $error } +tac-error-invalid-argument = { $argument } : erreur de lecture : Argument invalide +tac-error-file-not-found = échec de l'ouverture de { $filename } en lecture : Aucun fichier ou répertoire de ce type +tac-error-read-error = échec de la lecture depuis { $filename } : { $error } +tac-error-write-error = échec de l'écriture vers stdout : { $error } diff --git a/src/uu/tac/src/error.rs b/src/uu/tac/src/error.rs index fc01bbffd..6018bcc62 100644 --- a/src/uu/tac/src/error.rs +++ b/src/uu/tac/src/error.rs @@ -3,37 +3,35 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. //! Errors returned by tac during processing of a file. -use thiserror::Error; +use std::collections::HashMap; +use thiserror::Error; use uucore::display::Quotable; use uucore::error::UError; +use uucore::locale::get_message_with_args; #[derive(Debug, Error)] pub enum TacError { /// A regular expression given by the user is invalid. - #[error("invalid regular expression: {0}")] + #[error("{}", get_message_with_args("tac-error-invalid-regex", HashMap::from([("error".to_string(), .0.to_string())])))] InvalidRegex(regex::Error), - /// An argument to tac is invalid. - #[error("{}: read error: Invalid argument", _0.maybe_quote())] + #[error("{}", get_message_with_args("tac-error-invalid-argument", HashMap::from([("argument".to_string(), .0.maybe_quote().to_string())])))] InvalidArgument(String), - /// The specified file is not found on the filesystem. - #[error("failed to open {} for reading: No such file or directory", _0.quote())] + #[error("{}", get_message_with_args("tac-error-file-not-found", HashMap::from([("filename".to_string(), .0.quote().to_string())])))] FileNotFound(String), - /// An error reading the contents of a file or stdin. /// /// The parameters are the name of the file and the underlying /// [`std::io::Error`] that caused this error. - #[error("failed to read from {0}: {1}")] + #[error("{}", get_message_with_args("tac-error-read-error", HashMap::from([("filename".to_string(), .0.clone()), ("error".to_string(), .1.to_string())])))] ReadError(String, std::io::Error), - /// An error writing the (reversed) contents of a file or stdin. /// /// The parameter is the underlying [`std::io::Error`] that caused /// this error. - #[error("failed to write to stdout: {0}")] + #[error("{}", get_message_with_args("tac-error-write-error", HashMap::from([("error".to_string(), .0.to_string())])))] WriteError(std::io::Error), } diff --git a/src/uu/tac/src/tac.rs b/src/uu/tac/src/tac.rs index 0cb2009a9..f24d2ec0f 100644 --- a/src/uu/tac/src/tac.rs +++ b/src/uu/tac/src/tac.rs @@ -64,21 +64,21 @@ pub fn uu_app() -> Command { Arg::new(options::BEFORE) .short('b') .long(options::BEFORE) - .help("attach the separator before instead of after") + .help(get_message("tac-help-before")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::REGEX) .short('r') .long(options::REGEX) - .help("interpret the sequence as a regular expression") + .help(get_message("tac-help-regex")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::SEPARATOR) .short('s') .long(options::SEPARATOR) - .help("use STRING as the separator instead of newline") + .help(get_message("tac-help-separator")) .value_name("STRING"), ) .arg(