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

Merge pull request #8088 from sylvestre/l10n-sync

l10n: port sync to translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-07 14:38:07 +02:00 committed by GitHub
commit 8d626cfd55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 58 additions and 13 deletions

View file

@ -1,2 +1,17 @@
sync-about = Synchronize cached writes to persistent storage sync-about = Synchronize cached writes to persistent storage
sync-usage = sync [OPTION]... FILE... sync-usage = sync [OPTION]... FILE...
# Help messages
sync-help-file-system = sync the file systems that contain the files (Linux and Windows only)
sync-help-data = sync only file data, no unneeded metadata (Linux only)
# Error messages
sync-error-data-needs-argument = --data needs at least one argument
sync-error-opening-file = error opening { $file }
sync-error-no-such-file = error opening { $file }: No such file or directory
# Windows-specific error messages
sync-error-flush-file-buffer = failed to flush file buffer
sync-error-create-volume-handle = failed to create volume handle
sync-error-find-first-volume = failed to find first volume
sync-error-find-next-volume = failed to find next volume

View file

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

View file

@ -12,14 +12,14 @@ use nix::errno::Errno;
use nix::fcntl::{OFlag, open}; use nix::fcntl::{OFlag, open};
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use nix::sys::stat::Mode; use nix::sys::stat::Mode;
use std::collections::HashMap;
use std::path::Path; use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
#[cfg(any(target_os = "linux", target_os = "android"))] #[cfg(any(target_os = "linux", target_os = "android"))]
use uucore::error::FromIo; use uucore::error::FromIo;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
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 FILE_SYSTEM: &str = "file-system"; pub static FILE_SYSTEM: &str = "file-system";
@ -67,6 +67,7 @@ mod platform {
use std::os::windows::prelude::*; use std::os::windows::prelude::*;
use std::path::Path; use std::path::Path;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
use uucore::locale::get_message;
use uucore::wide::{FromWide, ToWide}; use uucore::wide::{FromWide, ToWide};
use windows_sys::Win32::Foundation::{ use windows_sys::Win32::Foundation::{
ERROR_NO_MORE_FILES, GetLastError, HANDLE, INVALID_HANDLE_VALUE, MAX_PATH, ERROR_NO_MORE_FILES, GetLastError, HANDLE, INVALID_HANDLE_VALUE, MAX_PATH,
@ -92,7 +93,7 @@ mod platform {
if unsafe { FlushFileBuffers(file.as_raw_handle() as HANDLE) } == 0 { if unsafe { FlushFileBuffers(file.as_raw_handle() as HANDLE) } == 0 {
Err(USimpleError::new( Err(USimpleError::new(
get_last_error() as i32, get_last_error() as i32,
"failed to flush file buffer", get_message("sync-error-flush-file-buffer"),
)) ))
} else { } else {
Ok(()) Ok(())
@ -100,7 +101,7 @@ mod platform {
} }
Err(e) => Err(USimpleError::new( Err(e) => Err(USimpleError::new(
e.raw_os_error().unwrap_or(1), e.raw_os_error().unwrap_or(1),
"failed to create volume handle", get_message("sync-error-create-volume-handle"),
)), )),
} }
} else { } else {
@ -115,7 +116,7 @@ mod platform {
if handle == INVALID_HANDLE_VALUE { if handle == INVALID_HANDLE_VALUE {
return Err(USimpleError::new( return Err(USimpleError::new(
get_last_error() as i32, get_last_error() as i32,
"failed to find first volume", get_message("sync-error-find-first-volume"),
)); ));
} }
Ok((String::from_wide_null(&name), handle)) Ok((String::from_wide_null(&name), handle))
@ -137,7 +138,10 @@ mod platform {
unsafe { FindVolumeClose(next_volume_handle) }; unsafe { FindVolumeClose(next_volume_handle) };
Ok(volumes) Ok(volumes)
} }
err => Err(USimpleError::new(err as i32, "failed to find next volume")), err => Err(USimpleError::new(
err as i32,
get_message("sync-error-find-next-volume"),
)),
}; };
} else { } else {
volumes.push(String::from_wide_null(&name)); volumes.push(String::from_wide_null(&name));
@ -172,14 +176,16 @@ mod platform {
#[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<String> = matches let files: Vec<String> = matches
.get_many::<String>(ARG_FILES) .get_many::<String>(ARG_FILES)
.map(|v| v.map(ToString::to_string).collect()) .map(|v| v.map(ToString::to_string).collect())
.unwrap_or_default(); .unwrap_or_default();
if matches.get_flag(options::DATA) && files.is_empty() { if matches.get_flag(options::DATA) && files.is_empty() {
return Err(USimpleError::new(1, "--data needs at least one argument")); return Err(USimpleError::new(
1,
get_message("sync-error-data-needs-argument"),
));
} }
for f in &files { for f in &files {
@ -189,17 +195,24 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let path = Path::new(&f); let path = Path::new(&f);
if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) { if let Err(e) = open(path, OFlag::O_NONBLOCK, Mode::empty()) {
if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) { if e != Errno::EACCES || (e == Errno::EACCES && path.is_dir()) {
e.map_err_context(|| format!("error opening {}", f.quote()))?; e.map_err_context(|| {
get_message_with_args(
"sync-error-opening-file",
HashMap::from([("file".to_string(), f.quote().to_string())]),
)
})?;
} }
} }
} }
#[cfg(not(any(target_os = "linux", target_os = "android")))] #[cfg(not(any(target_os = "linux", target_os = "android")))]
{ {
if !Path::new(&f).exists() { if !Path::new(&f).exists() {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
format!("error opening {}: No such file or directory", f.quote()), get_message_with_args(
"sync-error-no-such-file",
HashMap::from([("file".to_string(), f.quote().to_string())]),
),
)); ));
} }
} }
@ -229,7 +242,7 @@ pub fn uu_app() -> Command {
.short('f') .short('f')
.long(options::FILE_SYSTEM) .long(options::FILE_SYSTEM)
.conflicts_with(options::DATA) .conflicts_with(options::DATA)
.help("sync the file systems that contain the files (Linux and Windows only)") .help(get_message("sync-help-file-system"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -237,7 +250,7 @@ pub fn uu_app() -> Command {
.short('d') .short('d')
.long(options::DATA) .long(options::DATA)
.conflicts_with(options::FILE_SYSTEM) .conflicts_with(options::FILE_SYSTEM)
.help("sync only file data, no unneeded metadata (Linux only)") .help(get_message("sync-help-data"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(