Skip to content

Commit 2a20e87

Browse files
committed
l10n: port basenc for translation + add french
1 parent 7e4877f commit 2a20e87

File tree

3 files changed

+80
-33
lines changed

3 files changed

+80
-33
lines changed

src/uu/basenc/locales/en-US.ftl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,18 @@ basenc-about = Encode/decode data and print to standard output
55
the formal alphabet. Use --ignore-garbage to attempt to recover
66
from any other non-alphabet bytes in the encoded stream.
77
basenc-usage = basenc [OPTION]... [FILE]
8+
9+
# Help messages for encoding formats
10+
basenc-help-base64 = same as 'base64' program
11+
basenc-help-base64url = file- and url-safe base64
12+
basenc-help-base32 = same as 'base32' program
13+
basenc-help-base32hex = extended hex alphabet base32
14+
basenc-help-base16 = hex encoding
15+
basenc-help-base2lsbf = bit string with least significant bit (lsb) first
16+
basenc-help-base2msbf = bit string with most significant bit (msb) first
17+
basenc-help-z85 = ascii85-like encoding;
18+
when encoding, input length must be a multiple of 4;
19+
when decoding, input length must be a multiple of 5
20+
21+
# Error messages
22+
basenc-error-missing-encoding-type = missing encoding type

src/uu/basenc/locales/fr-FR.ftl

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

src/uu/basenc/src/basenc.rs

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,49 @@ use uucore::{
1313
encoding::Format,
1414
error::{UResult, UUsageError},
1515
};
16-
const ENCODINGS: &[(&str, Format, &str)] = &[
17-
("base64", Format::Base64, "same as 'base64' program"),
18-
("base64url", Format::Base64Url, "file- and url-safe base64"),
19-
("base32", Format::Base32, "same as 'base32' program"),
20-
(
21-
"base32hex",
22-
Format::Base32Hex,
23-
"extended hex alphabet base32",
24-
),
25-
("base16", Format::Base16, "hex encoding"),
26-
(
27-
"base2lsbf",
28-
Format::Base2Lsbf,
29-
"bit string with least significant bit (lsb) first",
30-
),
31-
(
32-
"base2msbf",
33-
Format::Base2Msbf,
34-
"bit string with most significant bit (msb) first",
35-
),
36-
(
37-
"z85",
38-
Format::Z85,
39-
"ascii85-like encoding;\n\
40-
when encoding, input length must be a multiple of 4;\n\
41-
when decoding, input length must be a multiple of 5",
42-
),
43-
];
16+
17+
fn get_encodings() -> Vec<(&'static str, Format, String)> {
18+
vec![
19+
("base64", Format::Base64, get_message("basenc-help-base64")),
20+
(
21+
"base64url",
22+
Format::Base64Url,
23+
get_message("basenc-help-base64url"),
24+
),
25+
("base32", Format::Base32, get_message("basenc-help-base32")),
26+
(
27+
"base32hex",
28+
Format::Base32Hex,
29+
get_message("basenc-help-base32hex"),
30+
),
31+
("base16", Format::Base16, get_message("basenc-help-base16")),
32+
(
33+
"base2lsbf",
34+
Format::Base2Lsbf,
35+
get_message("basenc-help-base2lsbf"),
36+
),
37+
(
38+
"base2msbf",
39+
Format::Base2Msbf,
40+
get_message("basenc-help-base2msbf"),
41+
),
42+
("z85", Format::Z85, get_message("basenc-help-z85")),
43+
]
44+
}
4445

4546
pub fn uu_app() -> Command {
4647
let about: &'static str = Box::leak(get_message("basenc-about").into_boxed_str());
4748
let usage: &'static str = Box::leak(get_message("basenc-usage").into_boxed_str());
4849

50+
let encodings = get_encodings();
4951
let mut command = base_common::base_app(about, usage);
50-
for encoding in ENCODINGS {
52+
53+
for encoding in &encodings {
5154
let raw_arg = Arg::new(encoding.0)
5255
.long(encoding.0)
53-
.help(encoding.2)
56+
.help(&encoding.2)
5457
.action(ArgAction::SetTrue);
55-
let overriding_arg = ENCODINGS
58+
let overriding_arg = encodings
5659
.iter()
5760
.fold(raw_arg, |arg, enc| arg.overrides_with(enc.0));
5861
command = command.arg(overriding_arg);
@@ -64,10 +67,17 @@ fn parse_cmd_args(args: impl uucore::Args) -> UResult<(Config, Format)> {
6467
let matches = uu_app()
6568
.try_get_matches_from(args.collect_lossy())
6669
.with_exit_code(1)?;
67-
let format = ENCODINGS
70+
71+
let encodings = get_encodings();
72+
let format = encodings
6873
.iter()
6974
.find(|encoding| matches.get_flag(encoding.0))
70-
.ok_or_else(|| UUsageError::new(BASE_CMD_PARSE_ERROR, "missing encoding type"))?
75+
.ok_or_else(|| {
76+
UUsageError::new(
77+
BASE_CMD_PARSE_ERROR,
78+
&get_message("basenc-error-missing-encoding-type"),
79+
)
80+
})?
7181
.1;
7282
let config = Config::from(&matches)?;
7383
Ok((config, format))

0 commit comments

Comments
 (0)