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

l10n: port basenc for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-13 22:36:12 +02:00
parent c9f76d41a7
commit 20fa53b487
3 changed files with 80 additions and 33 deletions

View file

@ -5,3 +5,18 @@ basenc-about = Encode/decode data and print to standard output
the formal alphabet. Use --ignore-garbage to attempt to recover the formal alphabet. Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream. from any other non-alphabet bytes in the encoded stream.
basenc-usage = basenc [OPTION]... [FILE] basenc-usage = basenc [OPTION]... [FILE]
# Help messages for encoding formats
basenc-help-base64 = same as 'base64' program
basenc-help-base64url = file- and url-safe base64
basenc-help-base32 = same as 'base32' program
basenc-help-base32hex = extended hex alphabet base32
basenc-help-base16 = hex encoding
basenc-help-base2lsbf = bit string with least significant bit (lsb) first
basenc-help-base2msbf = bit string with most significant bit (msb) first
basenc-help-z85 = ascii85-like encoding;
when encoding, input length must be a multiple of 4;
when decoding, input length must be a multiple of 5
# Error messages
basenc-error-missing-encoding-type = missing encoding type

View file

@ -0,0 +1,22 @@
basenc-about = Encoder/décoder des données et afficher vers la sortie standard
Sans FICHIER, ou lorsque FICHIER est -, lire l'entrée standard.
Lors du décodage, l'entrée peut contenir des nouvelles lignes en plus des octets de
l'alphabet formel. Utilisez --ignore-garbage pour tenter de récupérer
depuis tout autre octet non-alphabétique dans le flux encodé.
basenc-usage = basenc [OPTION]... [FICHIER]
# Messages d'aide pour les formats d'encodage
basenc-help-base64 = identique au programme 'base64'
basenc-help-base64url = base64 sécurisé pour fichiers et URLs
basenc-help-base32 = identique au programme 'base32'
basenc-help-base32hex = base32 avec alphabet hexadécimal étendu
basenc-help-base16 = encodage hexadécimal
basenc-help-base2lsbf = chaîne de bits avec le bit de poids faible (lsb) en premier
basenc-help-base2msbf = chaîne de bits avec le bit de poids fort (msb) en premier
basenc-help-z85 = encodage de type ascii85 ;
lors de l'encodage, la longueur d'entrée doit être un multiple de 4 ;
lors du décodage, la longueur d'entrée doit être un multiple de 5
# Messages d'erreur
basenc-error-missing-encoding-type = type d'encodage manquant

View file

@ -13,46 +13,49 @@ use uucore::{
encoding::Format, encoding::Format,
error::{UResult, UUsageError}, error::{UResult, UUsageError},
}; };
const ENCODINGS: &[(&str, Format, &str)] = &[
("base64", Format::Base64, "same as 'base64' program"), fn get_encodings() -> Vec<(&'static str, Format, String)> {
("base64url", Format::Base64Url, "file- and url-safe base64"), vec![
("base32", Format::Base32, "same as 'base32' program"), ("base64", Format::Base64, get_message("basenc-help-base64")),
( (
"base32hex", "base64url",
Format::Base32Hex, Format::Base64Url,
"extended hex alphabet base32", get_message("basenc-help-base64url"),
), ),
("base16", Format::Base16, "hex encoding"), ("base32", Format::Base32, get_message("basenc-help-base32")),
( (
"base2lsbf", "base32hex",
Format::Base2Lsbf, Format::Base32Hex,
"bit string with least significant bit (lsb) first", get_message("basenc-help-base32hex"),
), ),
( ("base16", Format::Base16, get_message("basenc-help-base16")),
"base2msbf", (
Format::Base2Msbf, "base2lsbf",
"bit string with most significant bit (msb) first", Format::Base2Lsbf,
), get_message("basenc-help-base2lsbf"),
( ),
"z85", (
Format::Z85, "base2msbf",
"ascii85-like encoding;\n\ Format::Base2Msbf,
when encoding, input length must be a multiple of 4;\n\ get_message("basenc-help-base2msbf"),
when decoding, input length must be a multiple of 5", ),
), ("z85", Format::Z85, get_message("basenc-help-z85")),
]; ]
}
pub fn uu_app() -> Command { pub fn uu_app() -> Command {
let about: &'static str = Box::leak(get_message("basenc-about").into_boxed_str()); let about: &'static str = Box::leak(get_message("basenc-about").into_boxed_str());
let usage: &'static str = Box::leak(get_message("basenc-usage").into_boxed_str()); let usage: &'static str = Box::leak(get_message("basenc-usage").into_boxed_str());
let encodings = get_encodings();
let mut command = base_common::base_app(about, usage); let mut command = base_common::base_app(about, usage);
for encoding in ENCODINGS {
for encoding in &encodings {
let raw_arg = Arg::new(encoding.0) let raw_arg = Arg::new(encoding.0)
.long(encoding.0) .long(encoding.0)
.help(encoding.2) .help(&encoding.2)
.action(ArgAction::SetTrue); .action(ArgAction::SetTrue);
let overriding_arg = ENCODINGS let overriding_arg = encodings
.iter() .iter()
.fold(raw_arg, |arg, enc| arg.overrides_with(enc.0)); .fold(raw_arg, |arg, enc| arg.overrides_with(enc.0));
command = command.arg(overriding_arg); command = command.arg(overriding_arg);
@ -64,10 +67,17 @@ fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
let matches = uu_app() let matches = uu_app()
.try_get_matches_from(args.collect_lossy()) .try_get_matches_from(args.collect_lossy())
.with_exit_code(1)?; .with_exit_code(1)?;
let format = ENCODINGS
let encodings = get_encodings();
let format = encodings
.iter() .iter()
.find(|encoding| matches.get_flag(encoding.0)) .find(|encoding| matches.get_flag(encoding.0))
.ok_or_else(|| UUsageError::new(BASE_CMD_PARSE_ERROR, "missing encoding type"))? .ok_or_else(|| {
UUsageError::new(
BASE_CMD_PARSE_ERROR,
get_message("basenc-error-missing-encoding-type"),
)
})?
.1; .1;
let config = Config::from(&matches)?; let config = Config::from(&matches)?;
Ok((config, format)) Ok((config, format))