From 903b310ec6c6ab568faffa0452fa8dd250304705 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 22 Mar 2026 09:44:42 +0100 Subject: [PATCH] uudoc: make tldr attribution and disclaimer translatable --- src/bin/uudoc.rs | 13 +++++-------- src/uucore/locales/en-US.ftl | 4 ++++ src/uucore/locales/fr-FR.ftl | 4 ++++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/bin/uudoc.rs b/src/bin/uudoc.rs index a2395d3aee7..64959bc12df 100644 --- a/src/bin/uudoc.rs +++ b/src/bin/uudoc.rs @@ -25,6 +25,7 @@ use zip::ZipArchive; use coreutils::validation; use uucore::Args; +use uucore::locale::get_message; include!(concat!(env!("OUT_DIR"), "/uutils_map.rs")); @@ -246,6 +247,8 @@ fn main() -> io::Result<()> { } } let utils = util_map::>>(); + // Initialize localization for uucore common strings (used by tldr example attribution) + let _ = uucore::locale::setup_localization("uudoc"); match std::fs::create_dir("docs/src/utils/") { Err(e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()), x => x, @@ -693,15 +696,9 @@ fn format_examples(content: String, output_markdown: bool) -> Result The examples are provided by the [tldr-pages project](https://tldr.sh) under the [CC BY 4.0 License](https://github.com/tldr-pages/tldr/blob/main/LICENSE.md)." - )?; + writeln!(s, "> {}", get_message("uudoc-tldr-attribution"))?; writeln!(s, ">")?; - writeln!( - s, - "> Please note that, as uutils is a work in progress, some examples might fail." - )?; + writeln!(s, "> {}", get_message("uudoc-tldr-disclaimer"))?; Ok(s) } diff --git a/src/uucore/locales/en-US.ftl b/src/uucore/locales/en-US.ftl index 15896209526..93a76157768 100644 --- a/src/uucore/locales/en-US.ftl +++ b/src/uucore/locales/en-US.ftl @@ -80,3 +80,7 @@ checksum-failed-open-file = { $count -> *[other] { $count } listed files could not be read } checksum-error-algo-bad-format = { $file }: { $line }: improperly formatted { $algo } checksum line + +# uudoc tldr examples messages +uudoc-tldr-attribution = The examples are provided by the [tldr-pages project](https://tldr.sh) under the [CC BY 4.0 License](https://github.com/tldr-pages/tldr/blob/main/LICENSE.md). +uudoc-tldr-disclaimer = Please note that, as uutils is a work in progress, some examples might fail. diff --git a/src/uucore/locales/fr-FR.ftl b/src/uucore/locales/fr-FR.ftl index e9ff4abe475..98a18fbce39 100644 --- a/src/uucore/locales/fr-FR.ftl +++ b/src/uucore/locales/fr-FR.ftl @@ -74,3 +74,7 @@ checksum-failed-open-file = { $count -> *[other] { $count } fichiers passés n'ont pas pu être lu } checksum-error-algo-bad-format = { $file }: { $line }: ligne invalide pour { $algo } + +# Messages uudoc pour les exemples tldr +uudoc-tldr-attribution = Les exemples sont fournis par le [projet tldr-pages](https://tldr.sh) sous la [licence CC BY 4.0](https://github.com/tldr-pages/tldr/blob/main/LICENSE.md). +uudoc-tldr-disclaimer = Veuillez noter que, uutils étant en cours de développement, certains exemples peuvent échouer.