mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #8148 from sylvestre/l10n-cksum
l10n: port cksum for translation + add french
This commit is contained in:
commit
316466b9d3
3 changed files with 78 additions and 25 deletions
|
@ -14,3 +14,22 @@ cksum-after-help = DIGEST determines the digest algorithm and default output for
|
|||
- sha512: (equivalent to sha512sum)
|
||||
- blake2b: (equivalent to b2sum)
|
||||
- sm3: (only available through cksum)
|
||||
|
||||
# Help messages
|
||||
cksum-help-algorithm = select the digest type to use. See DIGEST below
|
||||
cksum-help-untagged = create a reversed style checksum, without digest type
|
||||
cksum-help-tag = create a BSD style checksum, undo --untagged (default)
|
||||
cksum-help-length = digest length in bits; must not exceed the max for the blake2 algorithm and must be a multiple of 8
|
||||
cksum-help-raw = emit a raw binary digest, not hexadecimal
|
||||
cksum-help-strict = exit non-zero for improperly formatted checksum lines
|
||||
cksum-help-check = read hashsums from the FILEs and check them
|
||||
cksum-help-base64 = emit a base64 digest, not hexadecimal
|
||||
cksum-help-warn = warn about improperly formatted checksum lines
|
||||
cksum-help-status = don't output anything, status code shows success
|
||||
cksum-help-quiet = don't print OK for each successfully verified file
|
||||
cksum-help-ignore-missing = don't fail or report status for missing files
|
||||
cksum-help-zero = end each output line with NUL, not newline, and disable file name escaping
|
||||
|
||||
# Error messages
|
||||
cksum-error-is-directory = { $file }: Is a directory
|
||||
cksum-error-failed-to-read-input = failed to read input
|
||||
|
|
35
src/uu/cksum/locales/fr-FR.ftl
Normal file
35
src/uu/cksum/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,35 @@
|
|||
cksum-about = Afficher le CRC et la taille de chaque fichier
|
||||
cksum-usage = cksum [OPTION]... [FICHIER]...
|
||||
cksum-after-help = DIGEST détermine l'algorithme de condensé et le format de sortie par défaut :
|
||||
|
||||
- sysv : (équivalent à sum -s)
|
||||
- bsd : (équivalent à sum -r)
|
||||
- crc : (équivalent à cksum)
|
||||
- crc32b : (disponible uniquement via cksum)
|
||||
- md5 : (équivalent à md5sum)
|
||||
- sha1 : (équivalent à sha1sum)
|
||||
- sha224 : (équivalent à sha224sum)
|
||||
- sha256 : (équivalent à sha256sum)
|
||||
- sha384 : (équivalent à sha384sum)
|
||||
- sha512 : (équivalent à sha512sum)
|
||||
- blake2b : (équivalent à b2sum)
|
||||
- sm3 : (disponible uniquement via cksum)
|
||||
|
||||
# Messages d'aide
|
||||
cksum-help-algorithm = sélectionner le type de condensé à utiliser. Voir DIGEST ci-dessous
|
||||
cksum-help-untagged = créer une somme de contrôle de style inversé, sans type de condensé
|
||||
cksum-help-tag = créer une somme de contrôle de style BSD, annuler --untagged (par défaut)
|
||||
cksum-help-length = longueur du condensé en bits ; ne doit pas dépasser le maximum pour l'algorithme blake2 et doit être un multiple de 8
|
||||
cksum-help-raw = émettre un condensé binaire brut, pas hexadécimal
|
||||
cksum-help-strict = sortir avec un code non-zéro pour les lignes de somme de contrôle mal formatées
|
||||
cksum-help-check = lire les sommes de hachage des FICHIERs et les vérifier
|
||||
cksum-help-base64 = émettre un condensé base64, pas hexadécimal
|
||||
cksum-help-warn = avertir des lignes de somme de contrôle mal formatées
|
||||
cksum-help-status = ne rien afficher, le code de statut indique le succès
|
||||
cksum-help-quiet = ne pas afficher OK pour chaque fichier vérifié avec succès
|
||||
cksum-help-ignore-missing = ne pas échouer ou signaler le statut pour les fichiers manquants
|
||||
cksum-help-zero = terminer chaque ligne de sortie avec NUL, pas un saut de ligne, et désactiver l'échappement des noms de fichiers
|
||||
|
||||
# Messages d'erreur
|
||||
cksum-error-is-directory = { $file } : Est un répertoire
|
||||
cksum-error-failed-to-read-input = échec de la lecture de l'entrée
|
|
@ -4,8 +4,10 @@
|
|||
// file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) fname, algo
|
||||
|
||||
use clap::builder::ValueParser;
|
||||
use clap::{Arg, ArgAction, Command, value_parser};
|
||||
use std::collections::HashMap;
|
||||
use std::ffi::{OsStr, OsString};
|
||||
use std::fs::File;
|
||||
use std::io::{self, BufReader, Read, Write, stdin, stdout};
|
||||
|
@ -17,7 +19,7 @@ use uucore::checksum::{
|
|||
ChecksumVerbose, SUPPORTED_ALGORITHMS, calculate_blake2b_length, detect_algo, digest_reader,
|
||||
perform_checksum_validation,
|
||||
};
|
||||
use uucore::locale::get_message;
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
use uucore::{
|
||||
encoding,
|
||||
error::{FromIo, UResult, USimpleError},
|
||||
|
@ -87,14 +89,17 @@ where
|
|||
if filename.is_dir() {
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
format!("{}: Is a directory", filename.display())
|
||||
get_message_with_args(
|
||||
"cksum-error-is-directory",
|
||||
HashMap::from([("file".to_string(), filename.display().to_string())])
|
||||
)
|
||||
));
|
||||
continue;
|
||||
}
|
||||
|
||||
let (sum_hex, sz) =
|
||||
digest_reader(&mut options.digest, &mut file, false, options.output_bits)
|
||||
.map_err_context(|| "failed to read input".to_string())?;
|
||||
.map_err_context(|| get_message("cksum-error-failed-to-read-input"))?;
|
||||
|
||||
let sum = match options.output_format {
|
||||
OutputFormat::Raw => {
|
||||
|
@ -118,6 +123,7 @@ where
|
|||
_ => encoding::for_cksum::BASE64.encode(&hex::decode(sum_hex).unwrap()),
|
||||
},
|
||||
};
|
||||
|
||||
// The BSD checksum output is 5 digit integer
|
||||
let bsd_width = 5;
|
||||
let (before_filename, should_print_filename, after_filename) = match options.algo_name {
|
||||
|
@ -171,6 +177,7 @@ where
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
print!("{before_filename}");
|
||||
if should_print_filename {
|
||||
// The filename might not be valid UTF-8, and filename.display() would mangle the names.
|
||||
|
@ -179,7 +186,6 @@ where
|
|||
}
|
||||
print!("{after_filename}{}", options.line_ending);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -279,6 +285,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
if tag || binary_flag || text_flag {
|
||||
return Err(ChecksumError::BinaryTextConflict.into());
|
||||
}
|
||||
|
||||
// Determine the appropriate algorithm option to pass
|
||||
let algo_option = if algo_name.is_empty() {
|
||||
None
|
||||
|
@ -294,7 +301,6 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
);
|
||||
|
||||
let verbose = ChecksumVerbose::new(status, quiet, warn);
|
||||
|
||||
let opts = ChecksumOptions {
|
||||
binary: binary_flag,
|
||||
ignore_missing,
|
||||
|
@ -355,21 +361,21 @@ pub fn uu_app() -> Command {
|
|||
Arg::new(options::ALGORITHM)
|
||||
.long(options::ALGORITHM)
|
||||
.short('a')
|
||||
.help("select the digest type to use. See DIGEST below")
|
||||
.help(get_message("cksum-help-algorithm"))
|
||||
.value_name("ALGORITHM")
|
||||
.value_parser(SUPPORTED_ALGORITHMS),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::UNTAGGED)
|
||||
.long(options::UNTAGGED)
|
||||
.help("create a reversed style checksum, without digest type")
|
||||
.help(get_message("cksum-help-untagged"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::TAG),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::TAG)
|
||||
.long(options::TAG)
|
||||
.help("create a BSD style checksum, undo --untagged (default)")
|
||||
.help(get_message("cksum-help-tag"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with(options::UNTAGGED),
|
||||
)
|
||||
|
@ -378,35 +384,32 @@ pub fn uu_app() -> Command {
|
|||
.long(options::LENGTH)
|
||||
.value_parser(value_parser!(usize))
|
||||
.short('l')
|
||||
.help(
|
||||
"digest length in bits; must not exceed the max for the blake2 algorithm \
|
||||
and must be a multiple of 8",
|
||||
)
|
||||
.help(get_message("cksum-help-length"))
|
||||
.action(ArgAction::Set),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::RAW)
|
||||
.long(options::RAW)
|
||||
.help("emit a raw binary digest, not hexadecimal")
|
||||
.help(get_message("cksum-help-raw"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::STRICT)
|
||||
.long(options::STRICT)
|
||||
.help("exit non-zero for improperly formatted checksum lines")
|
||||
.help(get_message("cksum-help-strict"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::CHECK)
|
||||
.short('c')
|
||||
.long(options::CHECK)
|
||||
.help("read hashsums from the FILEs and check them")
|
||||
.help(get_message("cksum-help-check"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::BASE64)
|
||||
.long(options::BASE64)
|
||||
.help("emit a base64 digest, not hexadecimal")
|
||||
.help(get_message("cksum-help-base64"))
|
||||
.action(ArgAction::SetTrue)
|
||||
// Even though this could easily just override an earlier '--raw',
|
||||
// GNU cksum does not permit these flags to be combined:
|
||||
|
@ -432,37 +435,35 @@ pub fn uu_app() -> Command {
|
|||
Arg::new(options::WARN)
|
||||
.short('w')
|
||||
.long("warn")
|
||||
.help("warn about improperly formatted checksum lines")
|
||||
.help(get_message("cksum-help-warn"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with_all([options::STATUS, options::QUIET]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::STATUS)
|
||||
.long("status")
|
||||
.help("don't output anything, status code shows success")
|
||||
.help(get_message("cksum-help-status"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with_all([options::WARN, options::QUIET]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::QUIET)
|
||||
.long(options::QUIET)
|
||||
.help("don't print OK for each successfully verified file")
|
||||
.help(get_message("cksum-help-quiet"))
|
||||
.action(ArgAction::SetTrue)
|
||||
.overrides_with_all([options::WARN, options::STATUS]),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::IGNORE_MISSING)
|
||||
.long(options::IGNORE_MISSING)
|
||||
.help("don't fail or report status for missing files")
|
||||
.help(get_message("cksum-help-ignore-missing"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::ZERO)
|
||||
.long(options::ZERO)
|
||||
.short('z')
|
||||
.help(
|
||||
"end each output line with NUL, not newline,\n and disable file name escaping",
|
||||
)
|
||||
.help(get_message("cksum-help-zero"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.after_help(get_message("cksum-after-help"))
|
||||
|
@ -478,9 +479,7 @@ mod tests {
|
|||
assert_eq!(calculate_blake2b_length(512).unwrap(), None);
|
||||
assert_eq!(calculate_blake2b_length(256).unwrap(), Some(32));
|
||||
calculate_blake2b_length(255).unwrap_err();
|
||||
|
||||
calculate_blake2b_length(33).unwrap_err();
|
||||
|
||||
calculate_blake2b_length(513).unwrap_err();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue