Skip to content

Commit ad7c6ea

Browse files
authored
Merge pull request #8140 from sylvestre/l10n-link
l10n: port link for translation + add french
2 parents b27c38e + 2a2301c commit ad7c6ea

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

src/uu/link/locales/en-US.ftl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
link-about = Call the link function to create a link named FILE2 to an existing FILE1.
22
link-usage = link FILE1 FILE2
3+
4+
link-error-cannot-create-link = cannot create link { $new } to { $old }

src/uu/link/locales/fr-FR.ftl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
link-about = Appelle la fonction link pour créer un lien nommé FILE2 vers un FILE1 existant.
2+
link-usage = link FILE1 FILE2
3+
4+
# Messages d'erreur
5+
link-error-cannot-create-link = impossible de créer le lien { $new } vers { $old }

src/uu/link/src/link.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@
22
//
33
// For the full copyright and license information, please view the LICENSE
44
// file that was distributed with this source code.
5+
56
use clap::builder::ValueParser;
67
use clap::{Arg, Command};
8+
use std::collections::HashMap;
79
use std::ffi::OsString;
810
use std::fs::hard_link;
911
use std::path::Path;
1012
use uucore::display::Quotable;
1113
use uucore::error::{FromIo, UResult};
1214
use uucore::format_usage;
13-
14-
use uucore::locale::get_message;
15+
use uucore::locale::{get_message, get_message_with_args};
1516

1617
pub mod options {
1718
pub static FILES: &str = "FILES";
@@ -20,16 +21,23 @@ pub mod options {
2021
#[uucore::main]
2122
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2223
let matches = uu_app().try_get_matches_from(args)?;
23-
2424
let files: Vec<_> = matches
2525
.get_many::<OsString>(options::FILES)
2626
.unwrap_or_default()
2727
.collect();
28+
2829
let old = Path::new(files[0]);
2930
let new = Path::new(files[1]);
3031

31-
hard_link(old, new)
32-
.map_err_context(|| format!("cannot create link {} to {}", new.quote(), old.quote()))
32+
hard_link(old, new).map_err_context(|| {
33+
get_message_with_args(
34+
"link-error-cannot-create-link",
35+
HashMap::from([
36+
("new".to_string(), new.quote().to_string()),
37+
("old".to_string(), old.quote().to_string()),
38+
]),
39+
)
40+
})
3341
}
3442

3543
pub fn uu_app() -> Command {

0 commit comments

Comments
 (0)