l10n: port tac for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-08 23:18:50 +02:00
parent 7e4877fb30
commit 39b51a8b9a
4 changed files with 33 additions and 13 deletions

View file

@ -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 }

View file

@ -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 }

View file

@ -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),
}

View file

@ -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(