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 {