1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

Merge pull request #8140 from sylvestre/l10n-link

l10n: port link for translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-11 12:43:18 +02:00 committed by GitHub
commit ad7c6eaff4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
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-about = Call the link function to create a link named FILE2 to an existing FILE1.
link-usage = link FILE1 FILE2 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 // For the full copyright and license information, please view the LICENSE
// file that was distributed with this source code. // file that was distributed with this source code.
use clap::builder::ValueParser; use clap::builder::ValueParser;
use clap::{Arg, Command}; use clap::{Arg, Command};
use std::collections::HashMap;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs::hard_link; use std::fs::hard_link;
use std::path::Path; use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult}; use uucore::error::{FromIo, UResult};
use uucore::format_usage; use uucore::format_usage;
use uucore::locale::{get_message, get_message_with_args};
use uucore::locale::get_message;
pub mod options { pub mod options {
pub static FILES: &str = "FILES"; pub static FILES: &str = "FILES";
@ -20,16 +21,23 @@ pub mod options {
#[uucore::main] #[uucore::main]
pub fn uumain(args: impl uucore::Args) -> UResult<()> { pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app().try_get_matches_from(args)?; let matches = uu_app().try_get_matches_from(args)?;
let files: Vec<_> = matches let files: Vec<_> = matches
.get_many::<OsString>(options::FILES) .get_many::<OsString>(options::FILES)
.unwrap_or_default() .unwrap_or_default()
.collect(); .collect();
let old = Path::new(files[0]); let old = Path::new(files[0]);
let new = Path::new(files[1]); let new = Path::new(files[1]);
hard_link(old, new) hard_link(old, new).map_err_context(|| {
.map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote())) 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 { pub fn uu_app() -> Command {