Skip to content

Commit 19103ee

Browse files
authored
Merge pull request #8287 from sylvestre/l10n-base32
l10n: port base32 for translation + add french
2 parents 97041c9 + 7bc0883 commit 19103ee

File tree

9 files changed

+135
-60
lines changed

9 files changed

+135
-60
lines changed

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# This file contains base32, base64 and basenc strings
2+
# This is because we have some common strings for all these tools
3+
# and it is easier to have a single file than one file for program
4+
# and loading several bundles at the same time.
5+
16
base32-about = encode/decode data and print to standard output
27
With no FILE, or when FILE is -, read standard input.
38
@@ -7,3 +12,47 @@ base32-about = encode/decode data and print to standard output
712
to attempt to recover from any other non-alphabet bytes in the
813
encoded stream.
914
base32-usage = base32 [OPTION]... [FILE]
15+
16+
base64-about = encode/decode data and print to standard output
17+
With no FILE, or when FILE is -, read standard input.
18+
19+
The data are encoded as described for the base64 alphabet in RFC 3548.
20+
When decoding, the input may contain newlines in addition
21+
to the bytes of the formal base64 alphabet. Use --ignore-garbage
22+
to attempt to recover from any other non-alphabet bytes in the
23+
encoded stream.
24+
base64-usage = base64 [OPTION]... [FILE]
25+
26+
basenc-about = Encode/decode data and print to standard output
27+
With no FILE, or when FILE is -, read standard input.
28+
29+
When decoding, the input may contain newlines in addition to the bytes of
30+
the formal alphabet. Use --ignore-garbage to attempt to recover
31+
from any other non-alphabet bytes in the encoded stream.
32+
basenc-usage = basenc [OPTION]... [FILE]
33+
34+
# Help messages for encoding formats
35+
basenc-help-base64 = same as 'base64' program
36+
basenc-help-base64url = file- and url-safe base64
37+
basenc-help-base32 = same as 'base32' program
38+
basenc-help-base32hex = extended hex alphabet base32
39+
basenc-help-base16 = hex encoding
40+
basenc-help-base2lsbf = bit string with least significant bit (lsb) first
41+
basenc-help-base2msbf = bit string with most significant bit (msb) first
42+
basenc-help-z85 = ascii85-like encoding;
43+
when encoding, input length must be a multiple of 4;
44+
when decoding, input length must be a multiple of 5
45+
46+
# Error messages
47+
basenc-error-missing-encoding-type = missing encoding type
48+
49+
# Shared base_common error messages (used by base32, base64, basenc)
50+
base-common-extra-operand = extra operand {$operand}
51+
base-common-no-such-file = {$file}: No such file or directory
52+
base-common-invalid-wrap-size = invalid wrap size: {$size}
53+
base-common-read-error = read error: {$error}
54+
55+
# Shared base_common help messages
56+
base-common-help-decode = decode data
57+
base-common-help-ignore-garbage = when decoding, ignore non-alphabetic characters
58+
base-common-help-wrap = wrap encoded lines after COLS character (default {$default}, 0 to disable wrapping)

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
base32-about = encoder/décoder les données et les imprimer sur la sortie standard
2+
Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard.
3+
4+
Les données sont encodées comme décrit pour l'alphabet base32 dans RFC 4648.
5+
Lors du décodage, l'entrée peut contenir des retours à la ligne en plus
6+
des octets de l'alphabet base32 formel. Utilisez --ignore-garbage
7+
pour tenter de récupérer des autres octets non-alphabétiques dans
8+
le flux encodé.
9+
base32-usage = base32 [OPTION]... [FICHIER]
10+
11+
base64-about = encoder/décoder les données et les imprimer sur la sortie standard
12+
Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard.
13+
14+
Les données sont encodées comme décrit pour l'alphabet base64 dans RFC 3548.
15+
Lors du décodage, l'entrée peut contenir des retours à la ligne en plus
16+
des octets de l'alphabet base64 formel. Utilisez --ignore-garbage
17+
pour tenter de récupérer des autres octets non-alphabétiques dans
18+
le flux encodé.
19+
base64-usage = base64 [OPTION]... [FICHIER]
20+
21+
basenc-about = Encoder/décoder des données et afficher vers la sortie standard
22+
Sans FICHIER, ou lorsque FICHIER est -, lire l'entrée standard.
23+
24+
Lors du décodage, l'entrée peut contenir des nouvelles lignes en plus des octets de
25+
l'alphabet formel. Utilisez --ignore-garbage pour tenter de récupérer
26+
depuis tout autre octet non-alphabétique dans le flux encodé.
27+
basenc-usage = basenc [OPTION]... [FICHIER]
28+
29+
# Messages d'aide pour les formats d'encodage
30+
basenc-help-base64 = identique au programme 'base64'
31+
basenc-help-base64url = base64 sécurisé pour fichiers et URLs
32+
basenc-help-base32 = identique au programme 'base32'
33+
basenc-help-base32hex = base32 avec alphabet hexadécimal étendu
34+
basenc-help-base16 = encodage hexadécimal
35+
basenc-help-base2lsbf = chaîne de bits avec le bit de poids faible (lsb) en premier
36+
basenc-help-base2msbf = chaîne de bits avec le bit de poids fort (msb) en premier
37+
basenc-help-z85 = encodage de type ascii85 ;
38+
lors de l'encodage, la longueur d'entrée doit être un multiple de 4 ;
39+
lors du décodage, la longueur d'entrée doit être un multiple de 5
40+
41+
# Messages d'erreur
42+
basenc-error-missing-encoding-type = type d'encodage manquant
43+
44+
# Messages d'erreur partagés de base_common (utilisés par base32, base64, basenc)
45+
base-common-extra-operand = opérande supplémentaire {$operand}
46+
base-common-no-such-file = {$file} : Aucun fichier ou répertoire de ce type
47+
base-common-invalid-wrap-size = taille de retour à la ligne invalide : {$size}
48+
base-common-read-error = erreur de lecture : {$error}
49+
50+
# Messages d'aide partagés de base_common
51+
base-common-help-decode = décoder les données
52+
base-common-help-ignore-garbage = lors du décodage, ignorer les caractères non-alphabétiques
53+
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)

src/uu/base32/src/base_common.rs

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// spell-checker:ignore hexupper lsbf msbf unpadded nopad aGVsbG8sIHdvcmxkIQ
77

88
use clap::{Arg, ArgAction, Command};
9+
use std::collections::HashMap;
910
use std::fs::File;
1011
use std::io::{self, ErrorKind, Read, Seek, SeekFrom};
1112
use std::path::{Path, PathBuf};
@@ -17,6 +18,7 @@ use uucore::encoding::{
1718
use uucore::encoding::{EncodingWrapper, SupportsFastDecodeAndEncode};
1819
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
1920
use uucore::format_usage;
21+
use uucore::locale::{get_message, get_message_with_args};
2022

2123
pub const BASE_CMD_PARSE_ERROR: i32 = 1;
2224

@@ -50,7 +52,10 @@ impl Config {
5052
if let Some(extra_op) = values.next() {
5153
return Err(UUsageError::new(
5254
BASE_CMD_PARSE_ERROR,
53-
format!("extra operand {}", extra_op.quote()),
55+
get_message_with_args(
56+
"base-common-extra-operand",
57+
HashMap::from([("operand".to_string(), extra_op.quote().to_string())]),
58+
),
5459
));
5560
}
5661

@@ -62,7 +67,13 @@ impl Config {
6267
if !path.exists() {
6368
return Err(USimpleError::new(
6469
BASE_CMD_PARSE_ERROR,
65-
format!("{}: No such file or directory", path.maybe_quote()),
70+
get_message_with_args(
71+
"base-common-no-such-file",
72+
HashMap::from([(
73+
"file".to_string(),
74+
path.maybe_quote().to_string(),
75+
)]),
76+
),
6677
));
6778
}
6879

@@ -78,7 +89,10 @@ impl Config {
7889
num.parse::<usize>().map_err(|_| {
7990
USimpleError::new(
8091
BASE_CMD_PARSE_ERROR,
81-
format!("invalid wrap size: {}", num.quote()),
92+
get_message_with_args(
93+
"base-common-invalid-wrap-size",
94+
HashMap::from([("size".to_string(), num.quote().to_string())]),
95+
),
8296
)
8397
})
8498
})
@@ -114,15 +128,15 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
114128
.short('d')
115129
.visible_short_alias('D')
116130
.long(options::DECODE)
117-
.help("decode data")
131+
.help(get_message("base-common-help-decode"))
118132
.action(ArgAction::SetTrue)
119133
.overrides_with(options::DECODE),
120134
)
121135
.arg(
122136
Arg::new(options::IGNORE_GARBAGE)
123137
.short('i')
124138
.long(options::IGNORE_GARBAGE)
125-
.help("when decoding, ignore non-alphabetic characters")
139+
.help(get_message("base-common-help-ignore-garbage"))
126140
.action(ArgAction::SetTrue)
127141
.overrides_with(options::IGNORE_GARBAGE),
128142
)
@@ -131,7 +145,10 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
131145
.short('w')
132146
.long(options::WRAP)
133147
.value_name("COLS")
134-
.help(format!("wrap encoded lines after COLS character (default {WRAP_DEFAULT}, 0 to disable wrapping)"))
148+
.help(get_message_with_args(
149+
"base-common-help-wrap",
150+
HashMap::from([("default".to_string(), WRAP_DEFAULT.to_string())]),
151+
))
135152
.overrides_with(options::WRAP),
136153
)
137154
// "multiple" arguments are used to check whether there is more than one
@@ -813,7 +830,10 @@ fn format_read_error(kind: ErrorKind) -> String {
813830
}
814831
}
815832

816-
format!("read error: {kind_string_capitalized}")
833+
get_message_with_args(
834+
"base-common-read-error",
835+
HashMap::from([("error".to_string(), kind_string_capitalized)]),
836+
)
817837
}
818838

819839
#[cfg(test)]

src/uu/base64/locales

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../base32/locales

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

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/uu/basenc/locales

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../base32/locales

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

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

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/by-util/test_base64.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,10 @@ cyBvdmVyIHRoZSBsYXp5IGRvZy4=
231231
#[test]
232232
fn test_manpage() {
233233
use std::process::{Command, Stdio};
234+
unsafe {
235+
// force locale to english to avoid issues with manpage output
236+
std::env::set_var("LANG", "C");
237+
}
234238

235239
let test_scenario = TestScenario::new("");
236240

0 commit comments

Comments
 (0)