From f98f2c130b3b69503930bcb9fb1b4dd3bd99ced2 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 14 Jun 2025 09:55:26 +0200 Subject: [PATCH] l10n: port nohup for translation + add french --- src/uu/nohup/locales/en-US.ftl | 9 +++++++++ src/uu/nohup/locales/fr-FR.ftl | 16 ++++++++++++++++ src/uu/nohup/src/nohup.rs | 35 +++++++++++++++++++++------------- 3 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 src/uu/nohup/locales/fr-FR.ftl diff --git a/src/uu/nohup/locales/en-US.ftl b/src/uu/nohup/locales/en-US.ftl index f209a7a90..1080a1832 100644 --- a/src/uu/nohup/locales/en-US.ftl +++ b/src/uu/nohup/locales/en-US.ftl @@ -5,3 +5,12 @@ nohup-after-help = If standard input is terminal, it'll be replaced with /dev/nu If standard output is terminal, it'll be appended to nohup.out instead, or $HOME/nohup.out, if nohup.out open failed. If standard error is terminal, it'll be redirected to stdout. + +# Error messages +nohup-error-cannot-detach = Cannot detach from console +nohup-error-cannot-replace = Cannot replace { $name }: { $err } +nohup-error-open-failed = failed to open { $path }: { $err } +nohup-error-open-failed-both = failed to open { $first_path }: { $first_err }\nfailed to open { $second_path }: { $second_err } + +# Status messages +nohup-ignoring-input-appending-output = ignoring input and appending output to { $path } diff --git a/src/uu/nohup/locales/fr-FR.ftl b/src/uu/nohup/locales/fr-FR.ftl new file mode 100644 index 000000000..5bf9a472a --- /dev/null +++ b/src/uu/nohup/locales/fr-FR.ftl @@ -0,0 +1,16 @@ +nohup-about = Exécuter COMMANDE en ignorant les signaux de raccrochage. +nohup-usage = nohup COMMANDE [ARG]... + nohup OPTION +nohup-after-help = Si l'entrée standard est un terminal, elle sera remplacée par /dev/null. + Si la sortie standard est un terminal, elle sera ajoutée à nohup.out à la place, + ou $HOME/nohup.out, si l'ouverture de nohup.out a échoué. + Si l'erreur standard est un terminal, elle sera redirigée vers la sortie standard. + +# Messages d'erreur +nohup-error-cannot-detach = Impossible de se détacher de la console +nohup-error-cannot-replace = Impossible de remplacer { $name } : { $err } +nohup-error-open-failed = échec de l'ouverture de { $path } : { $err } +nohup-error-open-failed-both = échec de l'ouverture de { $first_path } : { $first_err }\néchec de l'ouverture de { $second_path } : { $second_err } + +# Messages de statut +nohup-ignoring-input-appending-output = entrée ignorée et sortie ajoutée à { $path } diff --git a/src/uu/nohup/src/nohup.rs b/src/uu/nohup/src/nohup.rs index a855b01f1..dcc3ac168 100644 --- a/src/uu/nohup/src/nohup.rs +++ b/src/uu/nohup/src/nohup.rs @@ -8,6 +8,7 @@ use clap::{Arg, ArgAction, Command}; use libc::{SIG_IGN, SIGHUP}; use libc::{c_char, dup2, execvp, signal}; +use std::collections::HashMap; use std::env; use std::ffi::CString; use std::fs::{File, OpenOptions}; @@ -19,7 +20,8 @@ use uucore::display::Quotable; use uucore::error::{UClapError, UError, UResult, set_exit_code}; use uucore::{format_usage, show_error}; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; + static NOHUP_OUT: &str = "nohup.out"; // exit codes that match the GNU implementation static EXIT_CANCELED: i32 = 125; @@ -33,20 +35,21 @@ mod options { #[derive(Debug, Error)] enum NohupError { - #[error("Cannot detach from console")] + #[error("{}", get_message("nohup-error-cannot-detach"))] CannotDetach, - #[error("Cannot replace {name}: {err}", name = .0, err = .1)] + #[error("{}", get_message_with_args("nohup-error-cannot-replace", HashMap::from([("name".to_string(), _0.to_string()), ("err".to_string(), _1.to_string())])))] CannotReplace(&'static str, #[source] Error), - #[error("failed to open {path}: {err}", path = NOHUP_OUT.quote(), err = .1)] + #[error("{}", get_message_with_args("nohup-error-open-failed", HashMap::from([("path".to_string(), NOHUP_OUT.quote().to_string()), ("err".to_string(), _1.to_string())])))] OpenFailed(i32, #[source] Error), - #[error("failed to open {first_path}: {first_err}\nfailed to open {second_path}: {second_err}", - first_path = NOHUP_OUT.quote(), - first_err = .1, - second_path = .2.quote(), - second_err = .3)] + #[error("{}", get_message_with_args("nohup-error-open-failed-both", HashMap::from([ + ("first_path".to_string(), NOHUP_OUT.quote().to_string()), + ("first_err".to_string(), _1.to_string()), + ("second_path".to_string(), _2.quote().to_string()), + ("second_err".to_string(), _3.to_string()) + ])))] OpenFailed2(i32, #[source] Error, String, Error), } @@ -141,8 +144,11 @@ fn find_stdout() -> UResult { { Ok(t) => { show_error!( - "ignoring input and appending output to {}", - NOHUP_OUT.quote() + "{}", + get_message_with_args( + "nohup-ignoring-input-appending-output", + HashMap::from([("path".to_string(), NOHUP_OUT.quote().to_string())]) + ) ); Ok(t) } @@ -157,8 +163,11 @@ fn find_stdout() -> UResult { match OpenOptions::new().create(true).append(true).open(&homeout) { Ok(t) => { show_error!( - "ignoring input and appending output to {}", - homeout_str.quote() + "{}", + get_message_with_args( + "nohup-ignoring-input-appending-output", + HashMap::from([("path".to_string(), homeout_str.quote().to_string())]) + ) ); Ok(t) }