From 980c81a6ce1a159dfcfe815434a580c054f1af1a Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Wed, 4 Jun 2025 23:26:23 +0200 Subject: [PATCH] l10n: port whoami to translation + add french --- src/uu/whoami/locales/en-US.ftl | 4 ++++ src/uu/whoami/locales/fr-FR.ftl | 5 +++++ src/uu/whoami/src/whoami.rs | 8 +++----- 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 src/uu/whoami/locales/fr-FR.ftl diff --git a/src/uu/whoami/locales/en-US.ftl b/src/uu/whoami/locales/en-US.ftl index aedac774c..9d9b26130 100644 --- a/src/uu/whoami/locales/en-US.ftl +++ b/src/uu/whoami/locales/en-US.ftl @@ -1 +1,5 @@ whoami-about = Print the current username. + +# Error messages +whoami-error-failed-to-print = failed to print username +whoami-error-failed-to-get = failed to get username diff --git a/src/uu/whoami/locales/fr-FR.ftl b/src/uu/whoami/locales/fr-FR.ftl new file mode 100644 index 000000000..bb5ec1d02 --- /dev/null +++ b/src/uu/whoami/locales/fr-FR.ftl @@ -0,0 +1,5 @@ +whoami-about = Affiche le nom d'utilisateur actuel. + +# Messages d'erreur +whoami-error-failed-to-print = échec de l'affichage du nom d'utilisateur +whoami-error-failed-to-get = échec de l'obtention du nom d'utilisateur diff --git a/src/uu/whoami/src/whoami.rs b/src/uu/whoami/src/whoami.rs index 701d3a107..7e4276e90 100644 --- a/src/uu/whoami/src/whoami.rs +++ b/src/uu/whoami/src/whoami.rs @@ -3,10 +3,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -use std::ffi::OsString; - use clap::Command; - +use std::ffi::OsString; use uucore::display::println_verbatim; use uucore::error::{FromIo, UResult}; use uucore::locale::get_message; @@ -17,13 +15,13 @@ mod platform; pub fn uumain(args: impl uucore::Args) -> UResult<()> { uu_app().try_get_matches_from(args)?; let username = whoami()?; - println_verbatim(username).map_err_context(|| "failed to print username".into())?; + println_verbatim(username).map_err_context(|| get_message("whoami-error-failed-to-print"))?; Ok(()) } /// Get the current username pub fn whoami() -> UResult { - platform::get_username().map_err_context(|| "failed to get username".into()) + platform::get_username().map_err_context(|| get_message("whoami-error-failed-to-get")) } pub fn uu_app() -> Command {