8000 l10n: port chown for translation + add french by sylvestre · Pull Request #8260 · uutils/coreutils · GitHub
[go: up one dir, main page]

Skip to content

l10n: port chown for translation + add french #8260

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 24, 2025
Merged
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
20 changes: 20 additions & 0 deletions src/uu/chown/locales/en-US.ftl
Original file line number Diff line number Diff line change
@@ -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 changes: 23 additions & 0 deletions src/uu/chown/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -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 }
55 changes: 35 additions & 20 deletions src/uu/chown/src/chown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
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) {
Expand All @@ -35,8 +36,12 @@
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())]),

Check warning on line 42 in src/uu/chown/src/chown.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/chown/src/chown.rs#L39-L42

Added lines #L39 - L42 were not covered by tests
)
})?;

Check warning on line 44 in src/uu/chown/src/chown.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/chown/src/chown.rs#L44

Added line #L44 was not covered by tests
let gid = meta.gid();
let uid = meta.uid();
dest_gid = Some(gid);
Expand Down Expand Up @@ -84,56 +89,51 @@
.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..),
Expand All @@ -148,7 +148,7 @@
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
Expand Down Expand Up @@ -177,7 +177,10 @@
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())]),
),
)),
}
}
Expand All @@ -196,7 +199,10 @@
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())]),
),
)),
},
}
Expand Down Expand Up @@ -231,7 +237,10 @@
// 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())]),
),
));
}

Expand All @@ -241,9 +250,15 @@
#[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))));
Expand Down
Loading
0