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

l10n: port base32 for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-29 18:36:14 +02:00 committed by Sylvestre Ledru
parent c64adee068
commit e00167bd6b
3 changed files with 58 additions and 7 deletions

View file

@ -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 to attempt to recover from any other non-alphabet bytes in the
encoded stream. encoded stream.
base32-usage = base32 [OPTION]... [FILE] 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)

View file

@ -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)

View file

@ -6,6 +6,7 @@
// spell-checker:ignore hexupper lsbf msbf unpadded nopad aGVsbG8sIHdvcmxkIQ // spell-checker:ignore hexupper lsbf msbf unpadded nopad aGVsbG8sIHdvcmxkIQ
use clap::{Arg, ArgAction, Command}; use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io::{self, ErrorKind, Read, Seek, SeekFrom}; use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
@ -17,6 +18,7 @@ use uucore::encoding::{
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode}; use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
use uucore::error::{FromIo, UResult, USimpleError, UUsageError}; use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
use uucore::format_usage; use uucore::format_usage;
use uucore::locale::{get_message, get_message_with_args};
pub const BASE_CMD_PARSE_ERROR: i32 = 1; pub const BASE_CMD_PARSE_ERROR: i32 = 1;
@ -50,7 +52,10 @@ impl Config {
if let Some(extra_op) = values.next() { if let Some(extra_op) = values.next() {
return Err(UUsageError::new( return Err(UUsageError::new(
BASE_CMD_PARSE_ERROR, 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() { if !path.exists() {
return Err(USimpleError::new( return Err(USimpleError::new(
BASE_CMD_PARSE_ERROR, 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::<usize>().map_err(|_| { num.parse::<usize>().map_err(|_| {
USimpleError::new( USimpleError::new(
BASE_CMD_PARSE_ERROR, 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') .short('d')
.visible_short_alias('D') .visible_short_alias('D')
.long(options::DECODE) .long(options::DECODE)
.help("decode data") .help(get_message("base32-help-decode"))
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.overrides_with(options::DECODE), .overrides_with(options::DECODE),
) )
@ -122,7 +136,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
Arg::new(options::IGNORE_GARBAGE) Arg::new(options::IGNORE_GARBAGE)
.short('i') .short('i')
.long(options::IGNORE_GARBAGE) .long(options::IGNORE_GARBAGE)
.help("when decoding, ignore non-alphabetic characters") .help(get_message("base32-help-ignore-garbage"))
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.overrides_with(options::IGNORE_GARBAGE), .overrides_with(options::IGNORE_GARBAGE),
) )
@ -131,7 +145,10 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
.short('w') .short('w')
.long(options::WRAP) .long(options::WRAP)
.value_name("COLS") .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), .overrides_with(options::WRAP),
) )
// "multiple" arguments are used to check whether there is more than one // "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)] #[cfg(test)]