Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 44 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,7 @@ terminal_size = "0.4.0"
textwrap = { version = "0.16.1", features = ["terminal_size"] }
thiserror = "2.0.3"
time = { version = "0.3.36" }
rusty-fork = { version = "0.3.0" }
unicode-width = "0.2.0"
unit-prefix = "0.5"
utmp-classic = "0.1.6"
Expand Down
1 change: 0 additions & 1 deletion src/uu/cat/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ cat-help-ignored-u = (ignored)
cat-error-unknown-filetype = unknown filetype: { $ft_debug }
cat-error-is-directory = Is a directory
cat-error-input-file-is-output-file = input file is output file
cat-error-too-many-symbolic-links = Too many levels of symbolic links
cat-error-no-such-device-or-address = No such device or address
1 change: 0 additions & 1 deletion src/uu/cat/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,4 @@ cat-help-ignored-u = (ignoré)
cat-error-unknown-filetype = type de fichier inconnu : { $ft_debug }
cat-error-is-directory = Est un répertoire
cat-error-input-file-is-output-file = le fichier d'entrée est le fichier de sortie
cat-error-too-many-symbolic-links = Trop de niveaux de liens symboliques
cat-error-no-such-device-or-address = Aucun appareil ou adresse de ce type
2 changes: 1 addition & 1 deletion src/uu/cat/src/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ enum CatError {
NoSuchDeviceOrAddress,
#[error("{}", translate!("cat-error-input-file-is-output-file"))]
OutputIsInput,
#[error("{}", translate!("cat-error-too-many-symbolic-links"))]
#[error("{}", translate!("uio-err-too-many-symlinks"))]
TooManySymlinks,
}

Expand Down
5 changes: 2 additions & 3 deletions src/uu/du/src/du.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,9 +642,8 @@ fn du_regular(

// Check symlink depth limit
if current_symlink_depth > MAX_SYMLINK_DEPTH {
print_tx.send(Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"Too many levels of symbolic links",
print_tx.send(Err(std::io::Error::other(
translate!("uio-err-too-many-symlinks")
).map_err_context(
|| translate!("du-error-cannot-access", "path" => entry_path.quote()),
)))?;
Expand Down
3 changes: 1 addition & 2 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ fn parse_paths(files: &[OsString], opts: &Options) -> Vec<PathBuf> {
fn handle_two_paths(source: &Path, target: &Path, opts: &Options) -> UResult<()> {
// `mv` never follows a symlink source, so the guard must not either.
if backup_would_destroy_source(source, target, &opts.suffix, opts.backup, false) {
return Err(io::Error::new(
io::ErrorKind::NotFound,
return Err(io::Error::other(
translate!("mv-error-backup-might-destroy-source", "target" => target.quote(), "source" => source.quote()),
)
.into());
Expand Down
1 change: 1 addition & 0 deletions src/uucore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ thiserror = { workspace = true }

[dev-dependencies]
tempfile = { workspace = true }
rusty-fork = { workspace = true }

[target.'cfg(any(target_os = "linux", target_os = "android"))'.dependencies]
selinux = { workspace = true, optional = true }
Expand Down
20 changes: 20 additions & 0 deletions src/uucore/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ error-file-not-found = No such file or directory
error-invalid-argument = Invalid argument
error-is-a-directory = { $file }: Is a directory

uio-err-not-found = No such file or directory
uio-err-permission-denied = Permission denied
uio-err-conn-refused = Connection refused
uio-err-conn-reset = Connection reset
uio-err-conn-abort = Connection aborted
uio-err-not-connected = Not connected
uio-err-addr-in-use = Address in use
uio-err-addr-not-avail = Address not available
uio-err-broken-pipe = Broken pipe
uio-err-already-exists = Already exists
uio-err-would-block = Would block
uio-err-invalid-input = Invalid input
uio-err-invalid-data = Invalid data
uio-err-timed-out = Timed out
uio-err-write-zero = Write zero
uio-err-interrupted = Interrupted
uio-err-unexpected-eof = Unexpected end of file
uio-err-is-a-directory = Is a directory
uio-err-too-many-symlinks = Too many levels of symbolic links

# Common actions
action-copying = copying
action-moving = moving
Expand Down
20 changes: 20 additions & 0 deletions src/uucore/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,26 @@ error-file-not-found = Aucun fichier ou répertoire de ce type
error-invalid-argument = Argument invalide
error-is-a-directory = { $file }: Est un répertoire

uio-err-not-found = Aucun fichier ou répertoire de ce type

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just don't put the id then

uio-err-permission-denied = Permission refusée
uio-err-conn-refused = Connexion refusée
uio-err-conn-reset = Connexion réinitialisée
uio-err-conn-abort = Connexion interrompue
uio-err-not-connected = Déconnecté
# uio-err-addr-in-use = ?
# uio-err-addr-not-avail = ?
# uio-err-broken-pipe = ?
# uio-err-already-exists = ?
# uio-err-would-block = ?
# uio-err-invalid-input = ?
# uio-err-invalid-data = ?
# uio-err-timed-out = ?
# uio-err-write-zero = ?
# uio-err-interrupted = ?
# uio-err-unexpected-eof = ?
uio-err-is-a-directory = Est un répertoire
uio-err-too-many-symlinks = Trop de niveaux de liens symboliques

# Actions communes
action-copying = copie
action-moving = déplacement
Expand Down
14 changes: 4 additions & 10 deletions src/uucore/src/lib/features/checksum/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,20 +595,14 @@ fn get_input_file(filename: &OsStr) -> UResult<Box<dyn Read>> {
match File::open(filename) {
Ok(f) => {
if f.metadata()?.is_dir() {
Err(io::Error::other(
translate!("error-is-a-directory", "file" => filename.maybe_quote()),
)
.into())
Err(io::Error::from(io::ErrorKind::IsADirectory)
.map_err_context(|| filename.maybe_quote().to_string()))
} else {
Ok(Box::new(f))
}
}
Err(_) => Err(io::Error::other(format!(
"{}: {}",
filename.maybe_quote(),
translate!("error-file-not-found")
))
.into()),
Err(_) => Err(io::Error::from(io::ErrorKind::NotFound)
.map_err_context(|| filename.maybe_quote().to_string())),
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/uucore/src/lib/features/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use std::fs;
use std::fs::read_dir;
use std::hash::Hash;
use std::io::Stdin;
use std::io::{Error, ErrorKind, Result as IOResult};
use std::io::{Error, Result as IOResult};
#[cfg(any(unix, all(target_os = "wasi", target_env = "p2")))]
use std::os::fd::AsFd;
#[cfg(unix)]
Expand All @@ -38,6 +38,8 @@ use windows_sys::Win32::System::IO::DeviceIoControl;
#[cfg(windows)]
use windows_sys::Win32::System::Ioctl::FSCTL_SET_SPARSE;

use crate::translate;

/// Used to check if the `mode` has its `perm` bit set.
///
/// This macro expands to `mode & perm != 0`.
Expand Down Expand Up @@ -451,10 +453,7 @@ pub fn canonicalize<P: AsRef<Path>>(
path_to_follow.push(part.as_os_str());
}
if !visited_files.insert((file_info, path_to_follow)) {
return Err(Error::new(
ErrorKind::InvalidInput,
"Too many levels of symbolic links",
)); // TODO use ErrorKind::FilesystemLoop when stable
return Err(Error::other(translate!("uio-err-too-many-symlinks"))); // TODO use ErrorKind::FilesystemLoop when stable
}
}
result.pop();
Expand Down
2 changes: 1 addition & 1 deletion src/uucore/src/lib/features/perms.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ impl ChownExecutor {
if let Some(error) = e.io_error() {
strip_errno(error)
} else {
"Too many levels of symbolic links".into()
translate!("uio-err-too-many-symlinks")
}
);
} else {
Expand Down
39 changes: 21 additions & 18 deletions src/uucore/src/lib/mods/clap_localization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,28 +677,31 @@ mod tests {
}
}

#[test]
fn test_french_localization() {
use crate::locale::{get_message, setup_localization};
use std::env;
use rusty_fork::rusty_fork_test;
rusty_fork_test! {
#[test]
fn test_french_localization() {
use crate::locale::{get_message, setup_localization};
use std::env;

let original_lang = env::var_os("LANG").unwrap_or_default();
let original_lang = env::var_os("LANG").unwrap_or_default();

unsafe {
env::set_var("LANG", "fr_FR.UTF-8");
}
unsafe {
env::set_var("LANG", "fr_FR.UTF-8");
}

if setup_localization("test").is_ok() {
assert_eq!(get_message("common-error"), "erreur");
assert_eq!(get_message("common-usage"), "Utilisation");
assert_eq!(get_message("common-tip"), "conseil");
}
if setup_localization("test").is_ok() {
assert_eq!(get_message("common-error"), "erreur");
assert_eq!(get_message("common-usage"), "Utilisation");
assert_eq!(get_message("common-tip"), "conseil");
}

unsafe {
if original_lang.is_empty() {
env::remove_var("LANG");
} else {
env::set_var("LANG", original_lang);
unsafe {
if original_lang.is_empty() {
env::remove_var("LANG");
} else {
env::set_var("LANG", original_lang);
}
}
}
}
Expand Down
Loading
Loading