diff --git a/src/uu/link/locales/en-US.ftl b/src/uu/link/locales/en-US.ftl index 7a18c0900..77f7dc884 100644 --- a/src/uu/link/locales/en-US.ftl +++ b/src/uu/link/locales/en-US.ftl @@ -1,2 +1,4 @@ link-about = Call the link function to create a link named FILE2 to an existing FILE1. link-usage = link FILE1 FILE2 + +link-error-cannot-create-link = cannot create link { $new } to { $old } diff --git a/src/uu/link/locales/fr-FR.ftl b/src/uu/link/locales/fr-FR.ftl new file mode 100644 index 000000000..e2cb267f6 --- /dev/null +++ b/src/uu/link/locales/fr-FR.ftl @@ -0,0 +1,5 @@ +link-about = Appelle la fonction link pour créer un lien nommé FILE2 vers un FILE1 existant. +link-usage = link FILE1 FILE2 + +# Messages d'erreur +link-error-cannot-create-link = impossible de créer le lien { $new } vers { $old } diff --git a/src/uu/link/src/link.rs b/src/uu/link/src/link.rs index 5ff1760ba..1ba00bd1e 100644 --- a/src/uu/link/src/link.rs +++ b/src/uu/link/src/link.rs @@ -2,16 +2,17 @@ // // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. + use clap::builder::ValueParser; use clap::{Arg, Command}; +use std::collections::HashMap; use std::ffi::OsString; use std::fs::hard_link; use std::path::Path; 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}; pub mod options { pub static FILES: &str = "FILES"; @@ -20,16 +21,23 @@ pub mod options { #[uucore::main] pub fn uumain(args: impl uucore::Args) -> UResult<()> { let matches = uu_app().try_get_matches_from(args)?; - let files: Vec<_> = matches .get_many::(options::FILES) .unwrap_or_default() .collect(); + let old = Path::new(files[0]); let new = Path::new(files[1]); - hard_link(old, new) - .map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote())) + hard_link(old, new).map_err_context(|| { + get_message_with_args( + "link-error-cannot-create-link", + HashMap::from([ + ("new".to_string(), new.quote().to_string()), + ("old".to_string(), old.quote().to_string()), + ]), + ) + }) } pub fn uu_app() -> Command {