From 880e7e2e36a5587b55d7f16eea9d92081b8618d3 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sun, 8 Jun 2025 10:47:34 +0200 Subject: [PATCH] l10n: port unlink to translation + add french --- src/uu/unlink/locales/en-US.ftl | 1 + src/uu/unlink/locales/fr-FR.ftl | 4 ++++ src/uu/unlink/src/unlink.rs | 11 ++++++++--- 3 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 src/uu/unlink/locales/fr-FR.ftl diff --git a/src/uu/unlink/locales/en-US.ftl b/src/uu/unlink/locales/en-US.ftl index e819d905e..d2c768cb2 100644 --- a/src/uu/unlink/locales/en-US.ftl +++ b/src/uu/unlink/locales/en-US.ftl @@ -1,3 +1,4 @@ unlink-about = Unlink the file at FILE. unlink-usage = unlink FILE unlink OPTION +unlink-error-cannot-unlink = cannot unlink { $path } diff --git a/src/uu/unlink/locales/fr-FR.ftl b/src/uu/unlink/locales/fr-FR.ftl new file mode 100644 index 000000000..4d742837f --- /dev/null +++ b/src/uu/unlink/locales/fr-FR.ftl @@ -0,0 +1,4 @@ +unlink-about = Supprimer le lien vers le fichier FICHIER. +unlink-usage = unlink FICHIER + unlink OPTION +unlink-error-cannot-unlink = impossible de supprimer le lien { $path } diff --git a/src/uu/unlink/src/unlink.rs b/src/uu/unlink/src/unlink.rs index 418e59b6e..642e84eda 100644 --- a/src/uu/unlink/src/unlink.rs +++ b/src/uu/unlink/src/unlink.rs @@ -2,7 +2,7 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. - +use std::collections::HashMap; use std::ffi::OsString; use std::fs::remove_file; use std::path::Path; @@ -14,7 +14,7 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult}; use uucore::format_usage; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; static OPT_PATH: &str = "FILE"; #[uucore::main] @@ -23,7 +23,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { let path: &Path = matches.get_one::(OPT_PATH).unwrap().as_ref(); - remove_file(path).map_err_context(|| format!("cannot unlink {}", path.quote())) + remove_file(path).map_err_context(|| { + get_message_with_args( + "unlink-error-cannot-unlink", + HashMap::from([("path".to_string(), path.quote().to_string())]), + ) + }) } pub fn uu_app() -> Command {