mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #8168 from sylvestre/l10n-chgrp
l10n: port chgrp for translation + add french
This commit is contained in:
commit
c83c6d8966
3 changed files with 70 additions and 18 deletions
|
@ -1,3 +1,20 @@
|
||||||
chgrp-about = Change the group of each FILE to GROUP.
|
chgrp-about = Change the group of each FILE to GROUP.
|
||||||
chgrp-usage = chgrp [OPTION]... GROUP FILE...
|
chgrp-usage = chgrp [OPTION]... GROUP FILE...
|
||||||
chgrp [OPTION]... --reference=RFILE FILE...
|
chgrp [OPTION]... --reference=RFILE FILE...
|
||||||
|
|
||||||
|
# Help messages
|
||||||
|
chgrp-help-print-help = Print help information.
|
||||||
|
chgrp-help-changes = like verbose but report only when a change is made
|
||||||
|
chgrp-help-quiet = suppress most error messages
|
||||||
|
chgrp-help-verbose = output a diagnostic for every file processed
|
||||||
|
chgrp-help-preserve-root = fail to operate recursively on '/'
|
||||||
|
chgrp-help-no-preserve-root = do not treat '/' specially (the default)
|
||||||
|
chgrp-help-reference = use RFILE's group rather than specifying GROUP values
|
||||||
|
chgrp-help-from = change the group only if its current group matches GROUP
|
||||||
|
chgrp-help-recursive = operate on files and directories recursively
|
||||||
|
|
||||||
|
# Error messages
|
||||||
|
chgrp-error-invalid-group-id = invalid group id: '{ $gid_str }'
|
||||||
|
chgrp-error-invalid-group = invalid group: '{ $group }'
|
||||||
|
chgrp-error-failed-to-get-attributes = failed to get attributes of { $file }
|
||||||
|
chgrp-error-invalid-user = invalid user: '{ $from_group }'
|
||||||
|
|
20
src/uu/chgrp/locales/fr-FR.ftl
Normal file
20
src/uu/chgrp/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
chgrp-about = Changer le groupe de chaque FICHIER vers GROUPE.
|
||||||
|
chgrp-usage = chgrp [OPTION]... GROUPE FICHIER...
|
||||||
|
chgrp [OPTION]... --reference=RFICHIER FICHIER...
|
||||||
|
|
||||||
|
# Messages d'aide
|
||||||
|
chgrp-help-print-help = Afficher les informations d'aide.
|
||||||
|
chgrp-help-changes = comme verbeux mais rapporter seulement lors d'un changement
|
||||||
|
chgrp-help-quiet = supprimer la plupart des messages d'erreur
|
||||||
|
chgrp-help-verbose = afficher un diagnostic pour chaque fichier traité
|
||||||
|
chgrp-help-preserve-root = échouer à opérer récursivement sur '/'
|
||||||
|
chgrp-help-no-preserve-root = ne pas traiter '/' spécialement (par défaut)
|
||||||
|
chgrp-help-reference = utiliser le groupe de RFICHIER plutôt que spécifier les valeurs de GROUPE
|
||||||
|
chgrp-help-from = changer le groupe seulement si son groupe actuel correspond à GROUPE
|
||||||
|
chgrp-help-recursive = opérer sur les fichiers et répertoires récursivement
|
||||||
|
|
||||||
|
# Messages d'erreur
|
||||||
|
chgrp-error-invalid-group-id = identifiant de groupe invalide : '{ $gid_str }'
|
||||||
|
chgrp-error-invalid-group = groupe invalide : '{ $group }'
|
||||||
|
chgrp-error-failed-to-get-attributes = échec de l'obtention des attributs de { $file }
|
||||||
|
chgrp-error-invalid-user = utilisateur invalide : '{ $from_group }'
|
|
@ -12,26 +12,33 @@ use uucore::format_usage;
|
||||||
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
|
use uucore::perms::{GidUidOwnerFilter, IfFrom, chown_base, options};
|
||||||
|
|
||||||
use clap::{Arg, ArgAction, ArgMatches, Command};
|
use clap::{Arg, ArgAction, ArgMatches, Command};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
|
|
||||||
use uucore::locale::get_message;
|
use uucore::locale::{get_message, get_message_with_args};
|
||||||
|
|
||||||
fn parse_gid_from_str(group: &str) -> Result<u32, String> {
|
fn parse_gid_from_str(group: &str) -> Result<u32, String> {
|
||||||
if let Some(gid_str) = group.strip_prefix(':') {
|
if let Some(gid_str) = group.strip_prefix(':') {
|
||||||
// Handle :gid format
|
// Handle :gid format
|
||||||
gid_str
|
gid_str.parse::<u32>().map_err(|_| {
|
||||||
.parse::<u32>()
|
get_message_with_args(
|
||||||
.map_err(|_| format!("invalid group id: '{gid_str}'"))
|
"chgrp-error-invalid-group-id",
|
||||||
|
HashMap::from([("gid_str".to_string(), gid_str.to_string())]),
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// Try as group name first
|
// Try as group name first
|
||||||
match entries::grp2gid(group) {
|
match entries::grp2gid(group) {
|
||||||
Ok(g) => Ok(g),
|
Ok(g) => Ok(g),
|
||||||
// If group name lookup fails, try parsing as raw number
|
// If group name lookup fails, try parsing as raw number
|
||||||
Err(_) => group
|
Err(_) => group.parse::<u32>().map_err(|_| {
|
||||||
.parse::<u32>()
|
get_message_with_args(
|
||||||
.map_err(|_| format!("invalid group: '{group}'")),
|
"chgrp-error-invalid-group",
|
||||||
|
HashMap::from([("group".to_string(), group.to_string())]),
|
||||||
|
)
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +52,12 @@ fn get_dest_gid(matches: &ArgMatches) -> UResult<(Option<u32>, String)> {
|
||||||
raw_group = entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string());
|
raw_group = entries::gid2grp(gid).unwrap_or_else(|_| gid.to_string());
|
||||||
Some(gid)
|
Some(gid)
|
||||||
})
|
})
|
||||||
.map_err_context(|| format!("failed to get attributes of {}", file.quote()))?
|
.map_err_context(|| {
|
||||||
|
get_message_with_args(
|
||||||
|
"chgrp-error-failed-to-get-attributes",
|
||||||
|
HashMap::from([("file".to_string(), file.quote().to_string())]),
|
||||||
|
)
|
||||||
|
})?
|
||||||
} else {
|
} else {
|
||||||
let group = matches
|
let group = matches
|
||||||
.get_one::<String>(options::ARG_GROUP)
|
.get_one::<String>(options::ARG_GROUP)
|
||||||
|
@ -74,7 +86,10 @@ fn parse_gid_and_uid(matches: &ArgMatches) -> UResult<GidUidOwnerFilter> {
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
return Err(USimpleError::new(
|
return Err(USimpleError::new(
|
||||||
1,
|
1,
|
||||||
format!("invalid user: '{from_group}'"),
|
get_message_with_args(
|
||||||
|
"chgrp-error-invalid-user",
|
||||||
|
HashMap::from([("from_group".to_string(), from_group.to_string())]),
|
||||||
|
),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -105,14 +120,14 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::HELP)
|
Arg::new(options::HELP)
|
||||||
.long(options::HELP)
|
.long(options::HELP)
|
||||||
.help("Print help information.")
|
.help(get_message("chgrp-help-print-help"))
|
||||||
.action(ArgAction::Help),
|
.action(ArgAction::Help),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::CHANGES)
|
Arg::new(options::verbosity::CHANGES)
|
||||||
.short('c')
|
.short('c')
|
||||||
.long(options::verbosity::CHANGES)
|
.long(options::verbosity::CHANGES)
|
||||||
.help("like verbose but report only when a change is made")
|
.help(get_message("chgrp-help-changes"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -124,26 +139,26 @@ pub fn uu_app() -> Command {
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::QUIET)
|
Arg::new(options::verbosity::QUIET)
|
||||||
.long(options::verbosity::QUIET)
|
.long(options::verbosity::QUIET)
|
||||||
.help("suppress most error messages")
|
.help(get_message("chgrp-help-quiet"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::verbosity::VERBOSE)
|
Arg::new(options::verbosity::VERBOSE)
|
||||||
.short('v')
|
.short('v')
|
||||||
.long(options::verbosity::VERBOSE)
|
.long(options::verbosity::VERBOSE)
|
||||||
.help("output a diagnostic for every file processed")
|
.help(get_message("chgrp-help-verbose"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::preserve_root::PRESERVE)
|
Arg::new(options::preserve_root::PRESERVE)
|
||||||
.long(options::preserve_root::PRESERVE)
|
.long(options::preserve_root::PRESERVE)
|
||||||
.help("fail to operate recursively on '/'")
|
.help(get_message("chgrp-help-preserve-root"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::preserve_root::NO_PRESERVE)
|
Arg::new(options::preserve_root::NO_PRESERVE)
|
||||||
.long(options::preserve_root::NO_PRESERVE)
|
.long(options::preserve_root::NO_PRESERVE)
|
||||||
.help("do not treat '/' specially (the default)")
|
.help(get_message("chgrp-help-no-preserve-root"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
|
@ -151,19 +166,19 @@ pub fn uu_app() -> Command {
|
||||||
.long(options::REFERENCE)
|
.long(options::REFERENCE)
|
||||||
.value_name("RFILE")
|
.value_name("RFILE")
|
||||||
.value_hint(clap::ValueHint::FilePath)
|
.value_hint(clap::ValueHint::FilePath)
|
||||||
.help("use RFILE's group rather than specifying GROUP values"),
|
.help(get_message("chgrp-help-reference")),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::FROM)
|
Arg::new(options::FROM)
|
||||||
.long(options::FROM)
|
.long(options::FROM)
|
||||||
.value_name("GROUP")
|
.value_name("GROUP")
|
||||||
.help("change the group only if its current group matches GROUP"),
|
.help(get_message("chgrp-help-from")),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::RECURSIVE)
|
Arg::new(options::RECURSIVE)
|
||||||
.short('R')
|
.short('R')
|
||||||
.long(options::RECURSIVE)
|
.long(options::RECURSIVE)
|
||||||
.help("operate on files and directories recursively")
|
.help(get_message("chgrp-help-recursive"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
// Add common arguments with chgrp, chown & chmod
|
// Add common arguments with chgrp, chown & chmod
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue