diff --git a/src/uu/base32/locales/en-US.ftl b/src/uu/base32/locales/en-US.ftl index e3d2beb98..f1c00d31a 100644 --- a/src/uu/base32/locales/en-US.ftl +++ b/src/uu/base32/locales/en-US.ftl @@ -7,3 +7,14 @@ base32-about = encode/decode data and print to standard output to attempt to recover from any other non-alphabet bytes in the encoded stream. base32-usage = base32 [OPTION]... [FILE] + +# Error messages +base32-extra-operand = extra operand {$operand} +base32-no-such-file = {$file}: No such file or directory +base32-invalid-wrap-size = invalid wrap size: {$size} +base32-read-error = read error: {$error} + +# Help messages +base32-help-decode = decode data +base32-help-ignore-garbage = when decoding, ignore non-alphabetic characters +base32-help-wrap = wrap encoded lines after COLS character (default {$default}, 0 to disable wrapping) diff --git a/src/uu/base32/locales/fr-FR.ftl b/src/uu/base32/locales/fr-FR.ftl new file mode 100644 index 000000000..c38a9f153 --- /dev/null +++ b/src/uu/base32/locales/fr-FR.ftl @@ -0,0 +1,20 @@ +base32-about = encoder/décoder les données et les imprimer sur la sortie standard + Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard. + + Les données sont encodées comme décrit pour l'alphabet base32 dans RFC 4648. + Lors du décodage, l'entrée peut contenir des retours à la ligne en plus + des octets de l'alphabet base32 formel. Utilisez --ignore-garbage + pour tenter de récupérer des autres octets non-alphabétiques dans + le flux encodé. +base32-usage = base32 [OPTION]... [FICHIER] + +# Messages d'erreur +base32-extra-operand = opérande supplémentaire {$operand} +base32-no-such-file = {$file} : Aucun fichier ou répertoire de ce type +base32-invalid-wrap-size = taille de retour à la ligne invalide : {$size} +base32-read-error = erreur de lecture : {$error} + +# Messages d'aide +base32-help-decode = décoder les données +base32-help-ignore-garbage = lors du décodage, ignorer les caractères non-alphabétiques +base32-help-wrap = retour à la ligne des lignes encodées après COLS caractères (par défaut {$default}, 0 pour désactiver le retour à la ligne) diff --git a/src/uu/base32/src/base_common.rs b/src/uu/base32/src/base_common.rs index 05bfc89b2..5229b5155 100644 --- a/src/uu/base32/src/base_common.rs +++ b/src/uu/base32/src/base_common.rs @@ -6,6 +6,7 @@ // spell-checker:ignore hexupper lsbf msbf unpadded nopad aGVsbG8sIHdvcmxkIQ use clap::{Arg, ArgAction, Command}; +use std::collections::HashMap; use std::fs::File; use std::io::{self, ErrorKind, Read, Seek, SeekFrom}; use std::path::{Path, PathBuf}; @@ -17,6 +18,7 @@ use uucore::encoding::{ use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode}; use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::format_usage; +use uucore::locale::{get_message, get_message_with_args}; pub const BASE_CMD_PARSE_ERROR: i32 = 1; @@ -50,7 +52,10 @@ impl Config { if let Some(extra_op) = values.next() { return Err(UUsageError::new( BASE_CMD_PARSE_ERROR, - format!("extra operand {}", extra_op.quote()), + get_message_with_args( + "base32-extra-operand", + HashMap::from([("operand".to_string(), extra_op.quote().to_string())]), + ), )); } @@ -62,7 +67,13 @@ impl Config { if !path.exists() { return Err(USimpleError::new( BASE_CMD_PARSE_ERROR, - format!("{}: No such file or directory", path.maybe_quote()), + get_message_with_args( + "base32-no-such-file", + HashMap::from([( + "file".to_string(), + path.maybe_quote().to_string(), + )]), + ), )); } @@ -78,7 +89,10 @@ impl Config { num.parse::().map_err(|_| { USimpleError::new( BASE_CMD_PARSE_ERROR, - format!("invalid wrap size: {}", num.quote()), + get_message_with_args( + "base32-invalid-wrap-size", + HashMap::from([("size".to_string(), num.quote().to_string())]), + ), ) }) }) @@ -114,7 +128,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command { .short('d') .visible_short_alias('D') .long(options::DECODE) - .help("decode data") + .help(get_message("base32-help-decode")) .action(ArgAction::SetTrue) .overrides_with(options::DECODE), ) @@ -122,7 +136,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command { Arg::new(options::IGNORE_GARBAGE) .short('i') .long(options::IGNORE_GARBAGE) - .help("when decoding, ignore non-alphabetic characters") + .help(get_message("base32-help-ignore-garbage")) .action(ArgAction::SetTrue) .overrides_with(options::IGNORE_GARBAGE), ) @@ -131,7 +145,10 @@ pub fn base_app(about: &'static str, usage: &str) -> Command { .short('w') .long(options::WRAP) .value_name("COLS") - .help(format!("wrap encoded lines after COLS character (default {WRAP_DEFAULT}, 0 to disable wrapping)")) + .help(get_message_with_args( + "base32-help-wrap", + HashMap::from([("default".to_string(), WRAP_DEFAULT.to_string())]), + )) .overrides_with(options::WRAP), ) // "multiple" arguments are used to check whether there is more than one @@ -813,7 +830,10 @@ fn format_read_error(kind: ErrorKind) -> String { } } - format!("read error: {kind_string_capitalized}") + get_message_with_args( + "base32-read-error", + HashMap::from([("error".to_string(), kind_string_capitalized)]), + ) } #[cfg(test)]