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

l10n: port mkdir to translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-06 23:24:06 +02:00
parent df0ef3b589
commit 63a3d6e5b9
3 changed files with 67 additions and 17 deletions

View file

@ -1,3 +1,19 @@
mkdir-about = Create the given DIRECTORY(ies) if they do not exist mkdir-about = Create the given DIRECTORY(ies) if they do not exist
mkdir-usage = mkdir [OPTION]... DIRECTORY... mkdir-usage = mkdir [OPTION]... DIRECTORY...
mkdir-after-help = Each MODE is of the form [ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+. mkdir-after-help = Each MODE is of the form [ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+.
# Help messages
mkdir-help-mode = set file mode (not implemented on windows)
mkdir-help-parents = make parent directories as needed
mkdir-help-verbose = print a message for each printed directory
mkdir-help-selinux = set SELinux security context of each created directory to the default type
mkdir-help-context = like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX
# Error messages
mkdir-error-empty-directory-name = cannot create directory '': No such file or directory
mkdir-error-file-exists = { $path }: File exists
mkdir-error-failed-to-create-tree = failed to create whole tree
mkdir-error-cannot-set-permissions = cannot set permissions { $path }
# Verbose output
mkdir-verbose-created-directory = { $util_name }: created directory { $path }

View file

@ -0,0 +1,19 @@
mkdir-about = Créer les RÉPERTOIRE(s) donnés s'ils n'existent pas
mkdir-usage = mkdir [OPTION]... RÉPERTOIRE...
mkdir-after-help = Chaque MODE est de la forme [ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=]?[0-7]+.
# Messages d'aide
mkdir-help-mode = définir le mode de fichier (non implémenté sur Windows)
mkdir-help-parents = créer les répertoires parents si nécessaire
mkdir-help-verbose = afficher un message pour chaque répertoire créé
mkdir-help-selinux = définir le contexte de sécurité SELinux de chaque répertoire créé au type par défaut
mkdir-help-context = comme -Z, ou si CTX est spécifié, définir le contexte de sécurité SELinux ou SMACK à CTX
# Messages d'erreur
mkdir-error-empty-directory-name = impossible de créer le répertoire '' : Aucun fichier ou répertoire de ce type
mkdir-error-file-exists = { $path } : Le fichier existe
mkdir-error-failed-to-create-tree = échec de la création de l'arborescence complète
mkdir-error-cannot-set-permissions = impossible de définir les permissions { $path }
# Sortie détaillée
mkdir-verbose-created-directory = { $util_name } : répertoire créé { $path }

View file

@ -8,12 +8,13 @@
use clap::builder::ValueParser; use clap::builder::ValueParser;
use clap::parser::ValuesRef; use clap::parser::ValuesRef;
use clap::{Arg, ArgAction, ArgMatches, Command}; use clap::{Arg, ArgAction, ArgMatches, Command};
use std::collections::HashMap;
use std::ffi::OsString; use std::ffi::OsString;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
#[cfg(not(windows))] #[cfg(not(windows))]
use uucore::error::FromIo; use uucore::error::FromIo;
use uucore::error::{UResult, USimpleError}; use uucore::error::{UResult, USimpleError};
use uucore::locale::get_message; use uucore::locale::{get_message, get_message_with_args};
#[cfg(not(windows))] #[cfg(not(windows))]
use uucore::mode; use uucore::mode;
use uucore::{display::Quotable, fs::dir_strip_dot_for_creation}; use uucore::{display::Quotable, fs::dir_strip_dot_for_creation};
@ -139,13 +140,13 @@ pub fn uu_app() -> Command {
Arg::new(options::MODE) Arg::new(options::MODE)
.short('m') .short('m')
.long(options::MODE) .long(options::MODE)
.help("set file mode (not implemented on windows)"), .help(get_message("mkdir-help-mode")),
) )
.arg( .arg(
Arg::new(options::PARENTS) Arg::new(options::PARENTS)
.short('p') .short('p')
.long(options::PARENTS) .long(options::PARENTS)
.help("make parent directories as needed") .help(get_message("mkdir-help-parents"))
.overrides_with(options::PARENTS) .overrides_with(options::PARENTS)
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
@ -153,18 +154,21 @@ pub fn uu_app() -> Command {
Arg::new(options::VERBOSE) Arg::new(options::VERBOSE)
.short('v') .short('v')
.long(options::VERBOSE) .long(options::VERBOSE)
.help("print a message for each printed directory") .help(get_message("mkdir-help-verbose"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::SELINUX) Arg::new(options::SELINUX)
.short('Z') .short('Z')
.help("set SELinux security context of each created directory to the default type") .help(get_message("mkdir-help-selinux"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg(Arg::new(options::CONTEXT).long(options::CONTEXT).value_name("CTX").help( .arg(
"like -Z, or if CTX is specified then set the SELinux or SMACK security context to CTX", Arg::new(options::CONTEXT)
)) .long(options::CONTEXT)
.value_name("CTX")
.help(get_message("mkdir-help-context")),
)
.arg( .arg(
Arg::new(options::DIRS) Arg::new(options::DIRS)
.action(ArgAction::Append) .action(ArgAction::Append)
@ -205,10 +209,9 @@ pub fn mkdir(path: &Path, config: &Config) -> UResult<()> {
if path.as_os_str().is_empty() { if path.as_os_str().is_empty() {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
"cannot create directory '': No such file or directory".to_owned(), get_message("mkdir-error-empty-directory-name"),
)); ));
} }
// Special case to match GNU's behavior: // Special case to match GNU's behavior:
// mkdir -p foo/. should work and just create foo/ // mkdir -p foo/. should work and just create foo/
// std::fs::create_dir("foo/."); fails in pure Rust // std::fs::create_dir("foo/."); fails in pure Rust
@ -222,8 +225,12 @@ fn chmod(path: &Path, mode: u32) -> UResult<()> {
use std::fs::{Permissions, set_permissions}; use std::fs::{Permissions, set_permissions};
use std::os::unix::fs::PermissionsExt; use std::os::unix::fs::PermissionsExt;
let mode = Permissions::from_mode(mode); let mode = Permissions::from_mode(mode);
set_permissions(path, mode) set_permissions(path, mode).map_err_context(|| {
.map_err_context(|| format!("cannot set permissions {}", path.quote())) get_message_with_args(
"mkdir-error-cannot-set-permissions",
HashMap::from([("path".to_string(), path.quote().to_string())]),
)
})
} }
#[cfg(windows)] #[cfg(windows)]
@ -240,7 +247,10 @@ fn create_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<()> {
if path_exists && !config.recursive { if path_exists && !config.recursive {
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
format!("{}: File exists", path.display()), get_message_with_args(
"mkdir-error-file-exists",
HashMap::from([("path".to_string(), path.to_string_lossy().to_string())]),
),
)); ));
} }
if path == Path::new("") { if path == Path::new("") {
@ -251,7 +261,7 @@ fn create_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<()> {
match path.parent() { match path.parent() {
Some(p) => create_dir(p, true, config)?, Some(p) => create_dir(p, true, config)?,
None => { None => {
USimpleError::new(1, "failed to create whole tree"); USimpleError::new(1, get_message("mkdir-error-failed-to-create-tree"));
} }
} }
} }
@ -260,9 +270,14 @@ fn create_dir(path: &Path, is_parent: bool, config: &Config) -> UResult<()> {
Ok(()) => { Ok(()) => {
if config.verbose { if config.verbose {
println!( println!(
"{}: created directory {}", "{}",
uucore::util_name(), get_message_with_args(
path.quote() "mkdir-verbose-created-directory",
HashMap::from([
("util_name".to_string(), uucore::util_name().to_string()),
("path".to_string(), path.quote().to_string())
])
)
); );
} }