Skip to content

Commit 1ddbc2a

Browse files
committed
l10n: port sync to translation + add french
1 parent df0ef3b commit 1ddbc2a

3 files changed

Lines changed: 58 additions & 13 deletions

File tree

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,17 @@
11
sync-about = Synchronize cached writes to persistent storage
22
sync-usage = sync [OPTION]... FILE...
3+
4+
# Help messages
5+
sync-help-file-system = sync the file systems that contain the files (Linux and Windows only)
6+
sync-help-data = sync only file data, no unneeded metadata (Linux only)
7+
8+
# Error messages
9+
sync-error-data-needs-argument = --data needs at least one argument
10+
sync-error-opening-file = error opening { $file }
11+
sync-error-no-such-file = error opening { $file }: No such file or directory
12+
13+
# Windows-specific error messages
14+
sync-error-flush-file-buffer = failed to flush file buffer
15+
sync-error-create-volume-handle = failed to create volume handle
16+
sync-error-find-first-volume = failed to find first volume
17+
sync-error-find-next-volume = failed to find next volume

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
sync-about = Synchroniser les écritures en cache vers le stockage persistant
2+
sync-usage = sync [OPTION]... FICHIER...
3+
4+
# Messages d'aide
5+
sync-help-file-system = synchroniser les systèmes de fichiers qui contiennent les fichiers (Linux et Windows uniquement)
6+
sync-help-data = synchroniser seulement les données des fichiers, pas les métadonnées inutiles (Linux uniquement)
7+
8+
# Messages d'erreur
9+
sync-error-data-needs-argument = --data nécessite au moins un argument
10+
sync-error-opening-file = erreur lors de l'ouverture de { $file }
11+
sync-error-no-such-file = erreur lors de l'ouverture de { $file } : Aucun fichier ou répertoire de ce type
12+
13+
# Messages d'erreur spécifiques à Windows
14+
sync-error-flush-file-buffer = échec du vidage du tampon de fichier
15+
sync-error-create-volume-handle = échec de la création du handle de volume
16+
sync-error-find-first-volume = échec de la recherche du premier volume
17+
sync-error-find-next-volume = échec de la recherche du volume suivant

src/uu/sync/src/sync.rs

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use nix::errno::Errno;
1212
use nix::fcntl::{OFlag, open};
1313
#[cfg(any(target_os = "linux", target_os = "android"))]
1414
use nix::sys::stat::Mode;
15+
use std::collections::HashMap;
1516
use std::path::Path;
1617
use uucore::display::Quotable;
1718
#[cfg(any(target_os = "linux", target_os = "android"))]
1819
use uucore::error::FromIo;
1920
use uucore::error::{UResult, USimpleError};
2021
use uucore::format_usage;
21-
22-
use uucore::locale::get_message;
22+
use uucore::locale::{get_message, get_message_with_args};
2323

2424
pub mod options {
2525
pub static FILE_SYSTEM: &str = "file-system";
@@ -67,6 +67,7 @@ mod platform {
6767
use std::os::windows::prelude::*;
6868
use std::path::Path;
6969
use uucore::error::{UResult, USimpleError};
70+
use uucore::locale::get_message;
7071
use uucore::wide::{FromWide, ToWide};
7172
use windows_sys::Win32::Foundation::{
7273
ERROR_NO_MORE_FILES, GetLastError, HANDLE, INVALID_HANDLE_VALUE, MAX_PATH,
@@ -92,15 +93,15 @@ mod platform {
9293
if unsafe { FlushFileBuffers(file.as_raw_handle() as HANDLE) } == 0 {
9394
Err(USimpleError::new(
9495
get_last_error() as i32,
95-
"failed to flush file buffer",
96+
get_message("sync-error-flush-file-buffer"),
9697
))
9798
} else {
9899
Ok(())
99100
}
100101
}
101102
Err(e) => Err(USimpleError::new(
102103
e.raw_os_error().unwrap_or(1),
103-
"failed to create volume handle",
104+
get_message("sync-error-create-volume-handle"),
104105
)),
105106
}
106107
} else {
@@ -115,7 +116,7 @@ mod platform {
115116
if handle == INVALID_HANDLE_VALUE {
116117
return Err(USimpleError::new(
117118
get_last_error() as i32,
118-
"failed to find first volume",
119+
get_message("sync-error-find-first-volume"),
119120
));
120121
}
121122
Ok((String::from_wide_null(&name), handle))
@@ -137,7 +138,10 @@ mod platform {
137138
unsafe { FindVolumeClose(next_volume_handle) };
138139
Ok(volumes)
139140
}
140-
err => Err(USimpleError::new(err as i32, "failed to find next volume")),
141+
err => Err(USimpleError::new(
142+
err as i32,
143+
get_message("sync-error-find-next-volume"),
144+
)),
141145
};
142146
} else {
143147
volumes.push(String::from_wide_null(&name));
@@ -172,14 +176,16 @@ mod platform {
172176
#[uucore::main]
173177
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
174178
let matches = uu_app().try_get_matches_from(args)?;
175-
176179
let files: Vec<String> = matches
177180
.get_many::<String>(ARG_FILES)
178181
.map(|v| v.map(ToString::to_string).collect())
179182
.unwrap_or_default();
180183

181184
if matches.get_flag(options::DATA) && files.is_empty() {
182-
return Err(USimpleError::new(1, "--data needs at least one argument"));
185+
return Err(USimpleError::new(
186+
1,
187+
get_message("sync-error-data-needs-argument"),
188+
));
183189
}
184190

185191
for f in &files {
@@ -189,17 +195,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
189195
let path = Path::new(&f);
190196
if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) {
191197
if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) {
192-
e.map_err_context(|| format!("error opening {}", f.quote()))?;
198+
e.map_err_context(|| {
199+
get_message_with_args(
200+
"sync-error-opening-file",
201+
HashMap::from([("file".to_string(), f.quote().to_string())]),
202+
)
203+
})?;
193204
}
194205
}
195206
}
196-
197207
#[cfg(not(any(target_os = "linux", target_os = "android")))]
198208
{
199209
if !Path::new(&f).exists() {
200210
return Err(USimpleError::new(
201211
1,
202-
format!("error opening {}: No such file or directory", f.quote()),
212+
get_message_with_args(
213+
"sync-error-no-such-file",
214+
HashMap::from([("file".to_string(), f.quote().to_string())]),
215+
),
203216
));
204217
}
205218
}
@@ -229,15 +242,15 @@ pub fn uu_app() -> Command {
229242
.short('f')
230243
.long(options::FILE_SYSTEM)
231244
.conflicts_with(options::DATA)
232-
.help("sync the file systems that contain the files (Linux and Windows only)")
245+
.help(get_message("sync-help-file-system"))
233246
.action(ArgAction::SetTrue),
234247
)
235248
.arg(
236249
Arg::new(options::DATA)
237250
.short('d')
238251
.long(options::DATA)
239252
.conflicts_with(options::FILE_SYSTEM)
240-
.help("sync only file data, no unneeded metadata (Linux only)")
253+
.help(get_message("sync-help-data"))
241254
.action(ArgAction::SetTrue),
242255
)
243256
.arg(

0 commit comments

Comments
 (0)