Merge pull request #8287 from sylvestre/l10n-base32

l10n: port base32 for translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-30 10:26:07 +02:00 committed by GitHub
commit 19103eefcd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 135 additions and 60 deletions

View file

@ -1,3 +1,8 @@
# This file contains base32, base64 and basenc strings
# This is because we have some common strings for all these tools
# and it is easier to have a single file than one file for program
# and loading several bundles at the same time.
base32-about = encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.
@ -7,3 +12,47 @@ 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]
base64-about = encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.
The data are encoded as described for the base64 alphabet in RFC 3548.
When decoding, the input may contain newlines in addition
to the bytes of the formal base64 alphabet. Use --ignore-garbage
to attempt to recover from any other non-alphabet bytes in the
encoded stream.
base64-usage = base64 [OPTION]... [FILE]
basenc-about = Encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.
When decoding, the input may contain newlines in addition to the bytes of
the formal alphabet. Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream.
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
# Shared base_common error messages (used by base32, base64, basenc)
base-common-extra-operand = extra operand {$operand}
base-common-no-such-file = {$file}: No such file or directory
base-common-invalid-wrap-size = invalid wrap size: {$size}
base-common-read-error = read error: {$error}
# Shared base_common help messages
base-common-help-decode = decode data
base-common-help-ignore-garbage = when decoding, ignore non-alphabetic characters
base-common-help-wrap = wrap encoded lines after COLS character (default {$default}, 0 to disable wrapping)

View file

@ -0,0 +1,53 @@
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]
base64-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 base64 dans RFC 3548.
Lors du décodage, l'entrée peut contenir des retours à la ligne en plus
des octets de l'alphabet base64 formel. Utilisez --ignore-garbage
pour tenter de récupérer des autres octets non-alphabétiques dans
le flux encodé.
base64-usage = base64 [OPTION]... [FICHIER]
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
# Messages d'erreur partagés de base_common (utilisés par base32, base64, basenc)
base-common-extra-operand = opérande supplémentaire {$operand}
base-common-no-such-file = {$file} : Aucun fichier ou répertoire de ce type
base-common-invalid-wrap-size = taille de retour à la ligne invalide : {$size}
base-common-read-error = erreur de lecture : {$error}
# Messages d'aide partagés de base_common
base-common-help-decode = décoder les données
base-common-help-ignore-garbage = lors du décodage, ignorer les caractères non-alphabétiques
base-common-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
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(
"base-common-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(
"base-common-no-such-file",
HashMap::from([(
"file".to_string(),
path.maybe_quote().to_string(),
)]),
),
));
}
@ -78,7 +89,10 @@ impl Config {
num.parse::<usize>().map_err(|_| {
USimpleError::new(
BASE_CMD_PARSE_ERROR,
format!("invalid wrap size: {}", num.quote()),
get_message_with_args(
"base-common-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("base-common-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("base-common-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(
"base-common-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(
"base-common-read-error",
HashMap::from([("error".to_string(), kind_string_capitalized)]),
)
}
#[cfg(test)]

1
src/uu/base64/locales Symbolic link
View file

@ -0,0 +1 @@
../base32/locales

View file

@ -1,9 +0,0 @@
base64-about = encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.
The data are encoded as described for the base64 alphabet in RFC 3548.
When decoding, the input may contain newlines in addition
to the bytes of the formal base64 alphabet. Use --ignore-garbage
to attempt to recover from any other non-alphabet bytes in the
encoded stream.
base64-usage = base64 [OPTION]... [FILE]

1
src/uu/basenc/locales Symbolic link
View file

@ -0,0 +1 @@
../base32/locales

View file

@ -1,22 +0,0 @@
basenc-about = Encode/decode data and print to standard output
With no FILE, or when FILE is -, read standard input.
When decoding, the input may contain newlines in addition to the bytes of
the formal alphabet. Use --ignore-garbage to attempt to recover
from any other non-alphabet bytes in the encoded stream.
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

@ -1,22 +0,0 @@
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

@ -231,6 +231,10 @@ cyBvdmVyIHRoZSBsYXp5IGRvZy4=
#[test]
fn test_manpage() {
use std::process::{Command, Stdio};
unsafe {
// force locale to english to avoid issues with manpage output
std::env::set_var("LANG", "C");
}
let test_scenario = TestScenario::new("");