From 7847894acf7f49f3b38394d5a77e23be72f4ff44 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 24 May 2025 20:54:17 +0200 Subject: [PATCH] arch: support translations --- src/uu/arch/arch.md | 11 ----------- src/uu/arch/locales/en-US.ftl | 5 +++++ src/uu/arch/locales/fr-FR.ftl | 5 +++++ src/uu/arch/src/arch.rs | 13 ++++++------- 4 files changed, 16 insertions(+), 18 deletions(-) delete mode 100644 src/uu/arch/arch.md create mode 100644 src/uu/arch/locales/en-US.ftl create mode 100644 src/uu/arch/locales/fr-FR.ftl diff --git a/src/uu/arch/arch.md b/src/uu/arch/arch.md deleted file mode 100644 index a4ba2e75f..000000000 --- a/src/uu/arch/arch.md +++ /dev/null @@ -1,11 +0,0 @@ -# arch - -``` -arch -``` - -Display machine architecture - -## After Help - -Determine architecture name for current machine. diff --git a/src/uu/arch/locales/en-US.ftl b/src/uu/arch/locales/en-US.ftl new file mode 100644 index 000000000..1646e5003 --- /dev/null +++ b/src/uu/arch/locales/en-US.ftl @@ -0,0 +1,5 @@ +# Error message when system architecture information cannot be retrieved +cannot-get-system = cannot get system name + +arch-about = Display machine architecture +arch-after-help = Determine architecture name for current machine. diff --git a/src/uu/arch/locales/fr-FR.ftl b/src/uu/arch/locales/fr-FR.ftl new file mode 100644 index 000000000..f08462a87 --- /dev/null +++ b/src/uu/arch/locales/fr-FR.ftl @@ -0,0 +1,5 @@ +# Error message when system architecture information cannot be retrieved +cannot-get-system = impossible d'obtenir le nom du système + +arch-about = Afficher l'architecture de la machine +arch-after-help = Déterminer le nom de l'architecture pour la machine actuelle. diff --git a/src/uu/arch/src/arch.rs b/src/uu/arch/src/arch.rs index 590def48f..82e9bb79e 100644 --- a/src/uu/arch/src/arch.rs +++ b/src/uu/arch/src/arch.rs @@ -7,16 +7,15 @@ use platform_info::*; use clap::Command; use uucore::error::{UResult, USimpleError}; -use uucore::{help_about, help_section}; - -static ABOUT: &str = help_about!("arch.md"); -static SUMMARY: &str = help_section!("after help", "arch.md"); +use uucore::locale::{self, get_message}; #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { + locale::setup_localization(uucore::util_name())?; uu_app().try_get_matches_from(args)?; - let uts = PlatformInfo::new().map_err(|_e| USimpleError::new(1, "cannot get system name"))?; + let uts = + PlatformInfo::new().map_err(|_e| USimpleError::new(1, get_message("cannot-get-system")))?; println!("{}", uts.machine().to_string_lossy().trim()); Ok(()) @@ -25,7 +24,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uu_app() -> Command { Command::new(uucore::util_name()) .version(uucore::crate_version!()) - .about(ABOUT) - .after_help(SUMMARY) + .about(get_message("arch-about")) + .after_help(get_message("arch-after-help")) .infer_long_args(true) }