1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

l10n: port link for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-10 21:23:53 +02:00
parent 7e4877fb30
commit 2a2301c875
3 changed files with 20 additions and 5 deletions

View file

@ -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 }

View file

@ -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 }

View file

@ -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::<OsString>(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 {