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

Merge pull request #8174 from sylvestre/l10n-rmdir

l10n: port rmdir for translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-14 11:18:36 +02:00 committed by GitHub
commit 0a71b2a32d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 56 additions and 11 deletions

View file

@ -1,2 +1,14 @@
rmdir-about = Remove the DIRECTORY(ies), if they are empty. rmdir-about = Remove the DIRECTORY(ies), if they are empty.
rmdir-usage = rmdir [OPTION]... DIRECTORY... rmdir-usage = rmdir [OPTION]... DIRECTORY...
# Help messages
rmdir-help-ignore-fail-non-empty = ignore each failure that is solely because a directory is non-empty
rmdir-help-parents = remove DIRECTORY and its ancestors; e.g., 'rmdir -p a/b/c' is similar to rmdir a/b/c a/b a
rmdir-help-verbose = output a diagnostic for every directory processed
# Error messages
rmdir-error-symbolic-link-not-followed = failed to remove { $path }: Symbolic link not followed
rmdir-error-failed-to-remove = failed to remove { $path }: { $err }
# Verbose output
rmdir-verbose-removing-directory = { $util_name }: removing directory, { $path }

View file

@ -0,0 +1,14 @@
rmdir-about = Supprimer les RÉPERTOIRE(S), s'ils sont vides.
rmdir-usage = rmdir [OPTION]... RÉPERTOIRE...
# Messages d'aide
rmdir-help-ignore-fail-non-empty = ignorer chaque échec qui est uniquement dû au fait qu'un répertoire n'est pas vide
rmdir-help-parents = supprimer RÉPERTOIRE et ses ancêtres ; p. ex., 'rmdir -p a/b/c' est similaire à rmdir a/b/c a/b a
rmdir-help-verbose = afficher un diagnostic pour chaque répertoire traité
# Messages d'erreur
rmdir-error-symbolic-link-not-followed = échec de la suppression de { $path } : Lien symbolique non suivi
rmdir-error-failed-to-remove = échec de la suppression de { $path } : { $err }
# Sortie détaillée
rmdir-verbose-removing-directory = { $util_name } : suppression du répertoire, { $path }

View file

@ -7,6 +7,7 @@
use clap::builder::ValueParser; use clap::builder::ValueParser;
use clap::{Arg, ArgAction, Command}; use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs::{read_dir, remove_dir}; use std::fs::{read_dir, remove_dir};
use std::io; use std::io;
@ -14,9 +15,9 @@ use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{UResult, set_exit_code, strip_errno}; use uucore::error::{UResult, set_exit_code, strip_errno};
use uucore::locale::{get_message, get_message_with_args};
use uucore::{format_usage, show_error, util_name}; use uucore::{format_usage, show_error, util_name};
use uucore::locale::get_message;
static OPT_IGNORE_FAIL_NON_EMPTY: &str = "ignore-fail-on-non-empty"; static OPT_IGNORE_FAIL_NON_EMPTY: &str = "ignore-fail-on-non-empty";
static OPT_PARENTS: &str = "parents"; static OPT_PARENTS: &str = "parents";
static OPT_VERBOSE: &str = "verbose"; static OPT_VERBOSE: &str = "verbose";
@ -72,15 +73,27 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let no_slash: &Path = OsStr::from_bytes(&bytes[..bytes.len() - 1]).as_ref(); let no_slash: &Path = OsStr::from_bytes(&bytes[..bytes.len() - 1]).as_ref();
if no_slash.is_symlink() && points_to_directory(no_slash).unwrap_or(true) { if no_slash.is_symlink() && points_to_directory(no_slash).unwrap_or(true) {
show_error!( show_error!(
"failed to remove {}: Symbolic link not followed", "{}",
path.quote() get_message_with_args(
"rmdir-error-symbolic-link-not-followed",
HashMap::from([("path".to_string(), path.quote().to_string())])
)
); );
continue; continue;
} }
} }
} }
show_error!("failed to remove {}: {}", path.quote(), strip_errno(&error)); show_error!(
"{}",
get_message_with_args(
"rmdir-error-failed-to-remove",
HashMap::from([
("path".to_string(), path.quote().to_string()),
("err".to_string(), strip_errno(&error).to_string())
])
)
);
} }
} }
@ -108,7 +121,16 @@ fn remove(mut path: &Path, opts: Opts) -> Result<(), Error<'_>> {
fn remove_single(path: &Path, opts: Opts) -> Result<(), Error<'_>> { fn remove_single(path: &Path, opts: Opts) -> Result<(), Error<'_>> {
if opts.verbose { if opts.verbose {
println!("{}: removing directory, {}", util_name(), path.quote()); println!(
"{}",
get_message_with_args(
"rmdir-verbose-removing-directory",
HashMap::from([
("util_name".to_string(), util_name().to_string()),
("path".to_string(), path.quote().to_string())
])
)
);
} }
remove_dir(path).map_err(|error| Error { error, path }) remove_dir(path).map_err(|error| Error { error, path })
} }
@ -170,24 +192,21 @@ pub fn uu_app() -> Command {
.arg( .arg(
Arg::new(OPT_IGNORE_FAIL_NON_EMPTY) Arg::new(OPT_IGNORE_FAIL_NON_EMPTY)
.long(OPT_IGNORE_FAIL_NON_EMPTY) .long(OPT_IGNORE_FAIL_NON_EMPTY)
.help("ignore each failure that is solely because a directory is non-empty") .help(get_message("rmdir-help-ignore-fail-non-empty"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(OPT_PARENTS) Arg::new(OPT_PARENTS)
.short('p') .short('p')
.long(OPT_PARENTS) .long(OPT_PARENTS)
.help( .help(get_message("rmdir-help-parents"))
"remove DIRECTORY and its ancestors; e.g.,
'rmdir -p a/b/c' is similar to rmdir a/b/c a/b a",
)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(OPT_VERBOSE) Arg::new(OPT_VERBOSE)
.short('v') .short('v')
.long(OPT_VERBOSE) .long(OPT_VERBOSE)
.help("output a diagnostic for every directory processed") .help(get_message("rmdir-help-verbose"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(