From 4e248d511ff2ac54fe6b54790023e3804c093bde Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Jun 2025 21:01:57 +0200 Subject: [PATCH] l10n: port tee for translation + add french --- src/uu/tee/locales/en-US.ftl | 17 +++++++++++++++++ src/uu/tee/locales/fr-FR.ftl | 20 ++++++++++++++++++++ src/uu/tee/src/tee.rs | 34 ++++++++++++++++++++-------------- 3 files changed, 57 insertions(+), 14 deletions(-) create mode 100644 src/uu/tee/locales/fr-FR.ftl diff --git a/src/uu/tee/locales/en-US.ftl b/src/uu/tee/locales/en-US.ftl index 2f0286958..4db948e6c 100644 --- a/src/uu/tee/locales/en-US.ftl +++ b/src/uu/tee/locales/en-US.ftl @@ -1,3 +1,20 @@ tee-about = Copy standard input to each FILE, and also to standard output. tee-usage = tee [OPTION]... [FILE]... tee-after-help = If a FILE is -, it refers to a file named - . + +# Help messages +tee-help-help = Print help +tee-help-append = append to the given FILEs, do not overwrite +tee-help-ignore-interrupts = ignore interrupt signals (ignored on non-Unix platforms) +tee-help-ignore-pipe-errors = set write error behavior (ignored on non-Unix platforms) +tee-help-output-error = set write error behavior +tee-help-output-error-warn = produce warnings for errors writing to any output +tee-help-output-error-warn-nopipe = produce warnings for errors that are not pipe errors (ignored on non-unix platforms) +tee-help-output-error-exit = exit on write errors to any output +tee-help-output-error-exit-nopipe = exit on write errors to any output that are not pipe errors (equivalent to exit on non-unix platforms) + +# Error messages +tee-error-stdin = stdin: { $error } + +# Other messages +tee-standard-output = 'standard output' diff --git a/src/uu/tee/locales/fr-FR.ftl b/src/uu/tee/locales/fr-FR.ftl new file mode 100644 index 000000000..eeea09ac4 --- /dev/null +++ b/src/uu/tee/locales/fr-FR.ftl @@ -0,0 +1,20 @@ +tee-about = Copier l'entrée standard vers chaque FICHIER, et aussi vers la sortie standard. +tee-usage = tee [OPTION]... [FICHIER]... +tee-after-help = Si un FICHIER est -, il fait référence à un fichier nommé - . + +# Messages d'aide +tee-help-help = Afficher l'aide +tee-help-append = ajouter aux FICHIERs donnés, ne pas écraser +tee-help-ignore-interrupts = ignorer les signaux d'interruption (ignoré sur les plateformes non-Unix) +tee-help-ignore-pipe-errors = définir le comportement d'erreur d'écriture (ignoré sur les plateformes non-Unix) +tee-help-output-error = définir le comportement d'erreur d'écriture +tee-help-output-error-warn = produire des avertissements pour les erreurs d'écriture vers toute sortie +tee-help-output-error-warn-nopipe = produire des avertissements pour les erreurs qui ne sont pas des erreurs de tube (ignoré sur les plateformes non-unix) +tee-help-output-error-exit = quitter en cas d'erreurs d'écriture vers toute sortie +tee-help-output-error-exit-nopipe = quitter en cas d'erreurs d'écriture vers toute sortie qui ne sont pas des erreurs de tube (équivalent à exit sur les plateformes non-unix) + +# Messages d'erreur +tee-error-stdin = stdin : { $error } + +# Autres messages +tee-standard-output = 'sortie standard' diff --git a/src/uu/tee/src/tee.rs b/src/uu/tee/src/tee.rs index e5269caf2..2adeb5e73 100644 --- a/src/uu/tee/src/tee.rs +++ b/src/uu/tee/src/tee.rs @@ -19,7 +19,8 @@ use uucore::{format_usage, show_error}; #[cfg(unix)] use uucore::signals::{enable_pipe_errors, ignore_interrupts}; -use uucore::locale::get_message; +use std::collections::HashMap; +use uucore::locale::{get_message, get_message_with_args}; mod options { pub const APPEND: &str = "append"; @@ -106,21 +107,21 @@ pub fn uu_app() -> Command { Arg::new("--help") .short('h') .long("help") - .help("Print help") - .action(ArgAction::HelpLong) + .help(get_message("tee-help-help")) + .action(ArgAction::HelpLong), ) .arg( Arg::new(options::APPEND) .long(options::APPEND) .short('a') - .help("append to the given FILEs, do not overwrite") + .help(get_message("tee-help-append")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::IGNORE_INTERRUPTS) .long(options::IGNORE_INTERRUPTS) .short('i') - .help("ignore interrupt signals (ignored on non-Unix platforms)") + .help(get_message("tee-help-ignore-interrupts")) .action(ArgAction::SetTrue), ) .arg( @@ -131,7 +132,7 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::IGNORE_PIPE_ERRORS) .short('p') - .help("set write error behavior (ignored on non-Unix platforms)") + .help(get_message("tee-help-ignore-pipe-errors")) .action(ArgAction::SetTrue), ) .arg( @@ -140,15 +141,14 @@ pub fn uu_app() -> Command { .require_equals(true) .num_args(0..=1) .value_parser(ShortcutValueParser::new([ - PossibleValue::new("warn") - .help("produce warnings for errors writing to any output"), + PossibleValue::new("warn").help(get_message("tee-help-output-error-warn")), PossibleValue::new("warn-nopipe") - .help("produce warnings for errors that are not pipe errors (ignored on non-unix platforms)"), - PossibleValue::new("exit").help("exit on write errors to any output"), + .help(get_message("tee-help-output-error-warn-nopipe")), + PossibleValue::new("exit").help(get_message("tee-help-output-error-exit")), PossibleValue::new("exit-nopipe") - .help("exit on write errors to any output that are not pipe errors (equivalent to exit on non-unix platforms)"), + .help(get_message("tee-help-output-error-exit-nopipe")), ])) - .help("set write error behavior") + .help(get_message("tee-help-output-error")), ) } @@ -175,7 +175,7 @@ fn tee(options: &Options) -> Result<()> { writers.insert( 0, NamedWriter { - name: "'standard output'".to_owned(), + name: get_message("tee-standard-output"), inner: Box::new(stdout()), }, ); @@ -373,7 +373,13 @@ impl Read for NamedReader { fn read(&mut self, buf: &mut [u8]) -> Result { match self.inner.read(buf) { Err(f) => { - show_error!("stdin: {f}"); + show_error!( + "{}", + get_message_with_args( + "tee-error-stdin", + HashMap::from([("error".to_string(), f.to_string())]) + ) + ); Err(f) } okay => okay,