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

Merge pull request #8074 from uutils/pr-2

l10n: port basename to translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-06 10:34:46 +02:00 committed by GitHub
commit 0a446cc7a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 35 additions and 6 deletions

View file

@ -2,3 +2,12 @@ basename-about = Print NAME with any leading directory components removed
If specified, also remove a trailing SUFFIX
basename-usage = basename [-z] NAME [SUFFIX]
basename OPTION... NAME...
# Error messages
basename-error-missing-operand = missing operand
basename-error-extra-operand = extra operand { $operand }
# Help text for command-line arguments
basename-help-multiple = support multiple arguments and treat each as a NAME
basename-help-suffix = remove a trailing SUFFIX; implies -a
basename-help-zero = end each output line with NUL, not newline

View file

@ -0,0 +1,13 @@
basename-about = Affiche NOM sans les composants de répertoire précédents
Si spécifié, supprime également un SUFFIXE final
basename-usage = basename [-z] NOM [SUFFIXE]
basename OPTION... NOM...
# Messages d'erreur
basename-error-missing-operand = opérande manquant
basename-error-extra-operand = opérande supplémentaire { $operand }
# Texte d'aide pour les arguments de ligne de commande
basename-help-multiple = prend en charge plusieurs arguments et traite chacun comme un NOM
basename-help-suffix = supprime un SUFFIXE final ; implique -a
basename-help-zero = termine chaque ligne de sortie avec NUL, pas nouvelle ligne

View file

@ -6,13 +6,14 @@
// spell-checker:ignore (ToDO) fullname
use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::path::{PathBuf, is_separator};
use uucore::display::Quotable;
use uucore::error::{UResult, UUsageError};
use uucore::format_usage;
use uucore::line_ending::LineEnding;
use uucore::locale::get_message;
use uucore::locale::{get_message, get_message_with_args};
pub mod options {
pub static MULTIPLE: &str = "multiple";
@ -37,7 +38,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.unwrap_or_default()
.collect::<Vec<_>>();
if name_args.is_empty() {
return Err(UUsageError::new(1, "missing operand".to_string()));
return Err(UUsageError::new(
1,
get_message("basename-error-missing-operand"),
));
}
let multiple_paths =
matches.get_one::<String>(options::SUFFIX).is_some() || matches.get_flag(options::MULTIPLE);
@ -55,7 +59,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
_ => {
return Err(UUsageError::new(
1,
format!("extra operand {}", name_args[2].quote()),
get_message_with_args(
"basename-error-extra-operand",
HashMap::from([("operand".to_string(), name_args[2].quote().to_string())]),
),
));
}
}
@ -82,7 +89,7 @@ pub fn uu_app() -> Command {
Arg::new(options::MULTIPLE)
.short('a')
.long(options::MULTIPLE)
.help("support multiple arguments and treat each as a NAME")
.help(get_message("basename-help-multiple"))
.action(ArgAction::SetTrue)
.overrides_with(options::MULTIPLE),
)
@ -98,14 +105,14 @@ pub fn uu_app() -> Command {
.short('s')
.long(options::SUFFIX)
.value_name("SUFFIX")
.help("remove a trailing SUFFIX; implies -a")
.help(get_message("basename-help-suffix"))
.overrides_with(options::SUFFIX),
)
.arg(
Arg::new(options::ZERO)
.short('z')
.long(options::ZERO)
.help("end each output line with NUL, not newline")
.help(get_message("basename-help-zero"))
.action(ArgAction::SetTrue)
.overrides_with(options::ZERO),
)