mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #8260 from sylvestre/l10n-chown
l10n: port chown for translation + add french
This commit is contained in:
commit
e5cdefe73a
3 changed files with 78 additions and 20 deletions
|
@ -1,3 +1,23 @@
|
|||
chown-about = Change file owner and group
|
||||
chown-usage = chown [OPTION]... [OWNER][:[GROUP]] FILE...
|
||||
chown [OPTION]... --reference=RFILE FILE...
|
||||
|
||||
# Help messages
|
||||
chown-help-print-help = Print help information.
|
||||
chown-help-changes = like verbose but report only when a change is made
|
||||
chown-help-from = change the owner and/or group of each file only if its
|
||||
current owner and/or group match those specified here.
|
||||
Either may be omitted, in which case a match is not required
|
||||
for the omitted attribute
|
||||
chown-help-preserve-root = fail to operate recursively on '/'
|
||||
chown-help-no-preserve-root = do not treat '/' specially (the default)
|
||||
chown-help-quiet = suppress most error messages
|
||||
chown-help-recursive = operate on files and directories recursively
|
||||
chown-help-reference = use RFILE's owner and group rather than specifying OWNER:GROUP values
|
||||
chown-help-verbose = output a diagnostic for every file processed
|
||||
|
||||
# Error messages
|
||||
chown-error-failed-to-get-attributes = failed to get attributes of { $file }
|
||||
chown-error-invalid-user = invalid user: { $user }
|
||||
chown-error-invalid-group = invalid group: { $group }
|
||||
chown-error-invalid-spec = invalid spec: { $spec }
|
||||
|
|
23
src/uu/chown/locales/fr-FR.ftl
Normal file
23
src/uu/chown/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,23 @@
|
|||
chown-about = Changer le propriétaire et le groupe des fichiers
|
||||
chown-usage = chown [OPTION]... [PROPRIÉTAIRE][:[GROUPE]] FICHIER...
|
||||
chown [OPTION]... --reference=RFICHIER FICHIER...
|
||||
|
||||
# Messages d'aide
|
||||
chown-help-print-help = Afficher les informations d'aide.
|
||||
chown-help-changes = comme verbeux mais rapporter seulement lors d'un changement
|
||||
chown-help-from = changer le propriétaire et/ou le groupe de chaque fichier seulement si son
|
||||
propriétaire et/ou groupe actuel correspondent à ceux spécifiés ici.
|
||||
L'un ou l'autre peut être omis, auquel cas une correspondance n'est pas requise
|
||||
pour l'attribut omis
|
||||
chown-help-preserve-root = échouer à opérer récursivement sur '/'
|
||||
chown-help-no-preserve-root = ne pas traiter '/' spécialement (par défaut)
|
||||
chown-help-quiet = supprimer la plupart des messages d'erreur
|
||||
chown-help-recursive = opérer sur les fichiers et répertoires récursivement
|
||||
chown-help-reference = utiliser le propriétaire et groupe de RFICHIER plutôt que spécifier les valeurs PROPRIÉTAIRE:GROUPE
|
||||
chown-help-verbose = afficher un diagnostic pour chaque fichier traité
|
||||
|
||||
# Messages d'erreur
|
||||
chown-error-failed-to-get-attributes = échec de l'obtention des attributs de { $file }
|
||||
chown-error-invalid-user = utilisateur invalide : { $user }
|
||||
chown-error-invalid-group = groupe invalide : { $group }
|
||||
chown-error-invalid-spec = spécification invalide : { $spec }
|
|
@ -17,7 +17,8 @@ use clap::{Arg, ArgAction, ArgMatches, Command};
|
|||
use std::fs;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
|
||||
use uucore::locale::get_message;
|
||||
use std::collections::HashMap;
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
|
||||
fn parse_gid_uid_and_filter(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
|
||||
let filter = if let Some(spec) = matches.get_one::<String>(options::FROM) {
|
||||
|
@ -35,8 +36,12 @@ fn parse_gid_uid_and_filter(matches: &ArgMatches) -> UResult<GidUidOwnerFilter>
|
|||
let dest_gid: Option<u32>;
|
||||
let raw_owner: String;
|
||||
if let Some(file) = matches.get_one::<String>(options::REFERENCE) {
|
||||
let meta = fs::metadata(file)
|
||||
.map_err_context(|| format!("failed to get attributes of {}", file.quote()))?;
|
||||
let meta = fs::metadata(file).map_err_context(|| {
|
||||
get_message_with_args(
|
||||
"chown-error-failed-to-get-attributes",
|
||||
HashMap::from([("file".to_string(), file.quote().to_string())]),
|
||||
)
|
||||
})?;
|
||||
let gid = meta.gid();
|
||||
let uid = meta.uid();
|
||||
dest_gid = Some(gid);
|
||||
|
@ -84,56 +89,51 @@ pub fn uu_app() -> Command {
|
|||
.arg(
|
||||
Arg::new(options::HELP)
|
||||
.long(options::HELP)
|
||||
.help("Print help information.")
|
||||
.help(get_message("chown-help-print-help"))
|
||||
.action(ArgAction::Help),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::verbosity::CHANGES)
|
||||
.short('c')
|
||||
.long(options::verbosity::CHANGES)
|
||||
.help("like verbose but report only when a change is made")
|
||||
.help(get_message("chown-help-changes"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::FROM)
|
||||
.long(options::FROM)
|
||||
.help(
|
||||
"change the owner and/or group of each file only if its \
|
||||
current owner and/or group match those specified here. \
|
||||
Either may be omitted, in which case a match is not required \
|
||||
for the omitted attribute",
|
||||
)
|
||||
.help(get_message("chown-help-from"))
|
||||
.value_name("CURRENT_OWNER:CURRENT_GROUP"),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::preserve_root::PRESERVE)
|
||||
.long(options::preserve_root::PRESERVE)
|
||||
.help("fail to operate recursively on '/'")
|
||||
.help(get_message("chown-help-preserve-root"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::preserve_root::NO_PRESERVE)
|
||||
.long(options::preserve_root::NO_PRESERVE)
|
||||
.help("do not treat '/' specially (the default)")
|
||||
.help(get_message("chown-help-no-preserve-root"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::verbosity::QUIET)
|
||||
.long(options::verbosity::QUIET)
|
||||
.help("suppress most error messages")
|
||||
.help(get_message("chown-help-quiet"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::RECURSIVE)
|
||||
.short('R')
|
||||
.long(options::RECURSIVE)
|
||||
.help("operate on files and directories recursively")
|
||||
.help(get_message("chown-help-recursive"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::REFERENCE)
|
||||
.long(options::REFERENCE)
|
||||
.help("use RFILE's owner and group rather than specifying OWNER:GROUP values")
|
||||
.help(get_message("chown-help-reference"))
|
||||
.value_name("RFILE")
|
||||
.value_hint(clap::ValueHint::FilePath)
|
||||
.num_args(1..),
|
||||
|
@ -148,7 +148,7 @@ pub fn uu_app() -> Command {
|
|||
Arg::new(options::verbosity::VERBOSE)
|
||||
.long(options::verbosity::VERBOSE)
|
||||
.short('v')
|
||||
.help("output a diagnostic for every file processed")
|
||||
.help(get_message("chown-help-verbose"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
// Add common arguments with chgrp, chown & chmod
|
||||
|
@ -177,7 +177,10 @@ fn parse_uid(user: &str, spec: &str, sep: char) -> UResult<Option<u32>> {
|
|||
Ok(uid) => Ok(Some(uid)),
|
||||
Err(_) => Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid user: {}", spec.quote()),
|
||||
get_message_with_args(
|
||||
"chown-error-invalid-user",
|
||||
HashMap::from([("user".to_string(), spec.quote().to_string())]),
|
||||
),
|
||||
)),
|
||||
}
|
||||
}
|
||||
|
@ -196,7 +199,10 @@ fn parse_gid(group: &str, spec: &str) -> UResult<Option<u32>> {
|
|||
Ok(gid) => Ok(Some(gid)),
|
||||
Err(_) => Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid group: {}", spec.quote()),
|
||||
get_message_with_args(
|
||||
"chown-error-invalid-group",
|
||||
HashMap::from([("group".to_string(), spec.quote().to_string())]),
|
||||
),
|
||||
)),
|
||||
},
|
||||
}
|
||||
|
@ -231,7 +237,10 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
|
|||
// we should fail with an error
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid spec: {}", spec.quote()),
|
||||
get_message_with_args(
|
||||
"chown-error-invalid-spec",
|
||||
HashMap::from([("spec".to_string(), spec.quote().to_string())]),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -241,9 +250,15 @@ fn parse_spec(spec: &str, sep: char) -> UResult<(Option<u32>, Option<u32>)> {
|
|||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use std::env;
|
||||
use uucore::locale;
|
||||
|
||||
#[test]
|
||||
fn test_parse_spec() {
|
||||
unsafe {
|
||||
env::set_var("LANG", "C");
|
||||
}
|
||||
let _ = locale::setup_localization("chown");
|
||||
assert!(matches!(parse_spec(":", ':'), Ok((None, None))));
|
||||
assert!(matches!(parse_spec(".", ':'), Ok((None, None))));
|
||||
assert!(matches!(parse_spec(".", '.'), Ok((None, None))));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue