diff --git a/src/uu/readlink/locales/en-US.ftl b/src/uu/readlink/locales/en-US.ftl index ddb806651..d784e62e1 100644 --- a/src/uu/readlink/locales/en-US.ftl +++ b/src/uu/readlink/locales/en-US.ftl @@ -1,2 +1,16 @@ readlink-about = Print value of a symbolic link or canonical file name. readlink-usage = readlink [OPTION]... [FILE]... + +# Help messages +readlink-help-canonicalize = canonicalize by following every symlink in every component of the given name recursively; all but the last component must exist +readlink-help-canonicalize-existing = canonicalize by following every symlink in every component of the given name recursively, all components must exist +readlink-help-canonicalize-missing = canonicalize by following every symlink in every component of the given name recursively, without requirements on components existence +readlink-help-no-newline = do not output the trailing delimiter +readlink-help-quiet = suppress most error messages +readlink-help-silent = suppress most error messages +readlink-help-verbose = report error message +readlink-help-zero = separate output with NUL rather than newline + +# Error messages +readlink-error-missing-operand = missing operand +readlink-error-ignoring-no-newline = ignoring --no-newline with multiple arguments diff --git a/src/uu/readlink/locales/fr-FR.ftl b/src/uu/readlink/locales/fr-FR.ftl new file mode 100644 index 000000000..e670f9c17 --- /dev/null +++ b/src/uu/readlink/locales/fr-FR.ftl @@ -0,0 +1,16 @@ +readlink-about = Afficher la valeur d'un lien symbolique ou le nom de fichier canonique. +readlink-usage = readlink [OPTION]... [FICHIER]... + +# Messages d'aide +readlink-help-canonicalize = canonicaliser en suivant chaque lien symbolique dans chaque composant du nom donné de manière récursive ; tous les composants sauf le dernier doivent exister +readlink-help-canonicalize-existing = canonicaliser en suivant chaque lien symbolique dans chaque composant du nom donné de manière récursive, tous les composants doivent exister +readlink-help-canonicalize-missing = canonicaliser en suivant chaque lien symbolique dans chaque composant du nom donné de manière récursive, sans exigences sur l'existence des composants +readlink-help-no-newline = ne pas afficher le délimiteur final +readlink-help-quiet = supprimer la plupart des messages d'erreur +readlink-help-silent = supprimer la plupart des messages d'erreur +readlink-help-verbose = signaler les messages d'erreur +readlink-help-zero = séparer la sortie avec NUL plutôt qu'une nouvelle ligne + +# Messages d'erreur +readlink-error-missing-operand = opérande manquant +readlink-error-ignoring-no-newline = ignorer --no-newline avec plusieurs arguments diff --git a/src/uu/readlink/src/readlink.rs b/src/uu/readlink/src/readlink.rs index f41e076a3..0710db199 100644 --- a/src/uu/readlink/src/readlink.rs +++ b/src/uu/readlink/src/readlink.rs @@ -13,9 +13,9 @@ use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::fs::{MissingHandling, ResolveMode, canonicalize}; use uucore::line_ending::LineEnding; +use uucore::locale::get_message; use uucore::{format_usage, show_error}; -use uucore::locale::get_message; const OPT_CANONICALIZE: &str = "canonicalize"; const OPT_CANONICALIZE_MISSING: &str = "canonicalize-missing"; const OPT_CANONICALIZE_EXISTING: &str = "canonicalize-existing"; @@ -57,14 +57,19 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { .get_many::(ARG_FILES) .map(|v| v.map(ToString::to_string).collect()) .unwrap_or_default(); + if files.is_empty() { - return Err(UUsageError::new(1, "missing operand")); + return Err(UUsageError::new( + 1, + get_message("readlink-error-missing-operand"), + )); } if no_trailing_delimiter && files.len() > 1 && !silent { - show_error!("ignoring --no-newline with multiple arguments"); + show_error!("{}", get_message("readlink-error-ignoring-no-newline")); no_trailing_delimiter = false; } + let line_ending = if no_trailing_delimiter { None } else { @@ -78,6 +83,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { } else { canonicalize(&p, can_mode, res_mode) }; + match path_result { Ok(path) => { show(&path, line_ending).map_err_context(String::new)?; @@ -108,65 +114,56 @@ pub fn uu_app() -> Command { Arg::new(OPT_CANONICALIZE) .short('f') .long(OPT_CANONICALIZE) - .help( - "canonicalize by following every symlink in every component of the \ - given name recursively; all but the last component must exist", - ) + .help(get_message("readlink-help-canonicalize")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_CANONICALIZE_EXISTING) .short('e') .long("canonicalize-existing") - .help( - "canonicalize by following every symlink in every component of the \ - given name recursively, all components must exist", - ) + .help(get_message("readlink-help-canonicalize-existing")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_CANONICALIZE_MISSING) .short('m') .long(OPT_CANONICALIZE_MISSING) - .help( - "canonicalize by following every symlink in every component of the \ - given name recursively, without requirements on components existence", - ) + .help(get_message("readlink-help-canonicalize-missing")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_NO_NEWLINE) .short('n') .long(OPT_NO_NEWLINE) - .help("do not output the trailing delimiter") + .help(get_message("readlink-help-no-newline")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_QUIET) .short('q') .long(OPT_QUIET) - .help("suppress most error messages") + .help(get_message("readlink-help-quiet")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_SILENT) .short('s') .long(OPT_SILENT) - .help("suppress most error messages") + .help(get_message("readlink-help-silent")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_VERBOSE) .short('v') .long(OPT_VERBOSE) - .help("report error message") + .help(get_message("readlink-help-verbose")) .action(ArgAction::SetTrue), ) .arg( Arg::new(OPT_ZERO) .short('z') .long(OPT_ZERO) - .help("separate output with NUL rather than newline") + .help(get_message("readlink-help-zero")) .action(ArgAction::SetTrue), ) .arg(