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

l10n: port sum for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-08 20:15:03 +02:00
parent 4128efad0f
commit 0b0e42340c
3 changed files with 32 additions and 6 deletions

View file

@ -2,3 +2,11 @@ sum-about = Checksum and count the blocks in a file.
With no FILE, or when FILE is -, read standard input. With no FILE, or when FILE is -, read standard input.
sum-usage = sum [OPTION]... [FILE]... sum-usage = sum [OPTION]... [FILE]...
# Help messages
sum-help-bsd-compatible = use the BSD sum algorithm, use 1K blocks (default)
sum-help-sysv-compatible = use System V sum algorithm, use 512 bytes blocks
# Error messages
sum-error-is-directory = { $name }: Is a directory
sum-error-no-such-file-or-directory = { $name }: No such file or directory

View file

@ -0,0 +1,12 @@
sum-about = Calculer la somme de contrôle et compter les blocs dans un fichier.
Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard.
sum-usage = sum [OPTION]... [FICHIER]...
# Messages d'aide
sum-help-bsd-compatible = utiliser l'algorithme de somme BSD, utiliser des blocs de 1K (par défaut)
sum-help-sysv-compatible = utiliser l'algorithme de somme System V, utiliser des blocs de 512 octets
# Messages d'erreur
sum-error-is-directory = { $name } : Est un répertoire
sum-error-no-such-file-or-directory = { $name } : Aucun fichier ou répertoire de ce type

View file

@ -6,15 +6,15 @@
// spell-checker:ignore (ToDO) sysv // spell-checker:ignore (ToDO) sysv
use clap::{Arg, ArgAction, Command}; use clap::{Arg, ArgAction, Command};
use std::collections::HashMap;
use std::fs::File; use std::fs::File;
use std::io::{ErrorKind, Read, Write, stdin, stdout}; use std::io::{ErrorKind, Read, Write, stdin, stdout};
use std::path::Path; use std::path::Path;
use uucore::display::Quotable; use uucore::display::Quotable;
use uucore::error::{FromIo, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
use uucore::locale::{get_message, get_message_with_args};
use uucore::{format_usage, show}; use uucore::{format_usage, show};
use uucore::locale::get_message;
fn bsd_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> { fn bsd_sum(mut reader: impl Read) -> std::io::Result<(usize, u16)> {
let mut buf = [0; 4096]; let mut buf = [0; 4096];
let mut bytes_read = 0; let mut bytes_read = 0;
@ -74,14 +74,20 @@ fn open(name: &str) -> UResult<Box<dyn Read>> {
if path.is_dir() { if path.is_dir() {
return Err(USimpleError::new( return Err(USimpleError::new(
2, 2,
format!("{}: Is a directory", name.maybe_quote()), get_message_with_args(
"sum-error-is-directory",
HashMap::from([("name".to_string(), name.maybe_quote().to_string())]),
),
)); ));
}; };
// Silent the warning as we want to the error message // Silent the warning as we want to the error message
if path.metadata().is_err() { if path.metadata().is_err() {
return Err(USimpleError::new( return Err(USimpleError::new(
2, 2,
format!("{}: No such file or directory", name.maybe_quote()), get_message_with_args(
"sum-error-no-such-file-or-directory",
HashMap::from([("name".to_string(), name.maybe_quote().to_string())]),
),
)); ));
}; };
let f = File::open(path).map_err_context(String::new)?; let f = File::open(path).map_err_context(String::new)?;
@ -149,14 +155,14 @@ pub fn uu_app() -> Command {
.arg( .arg(
Arg::new(options::BSD_COMPATIBLE) Arg::new(options::BSD_COMPATIBLE)
.short('r') .short('r')
.help("use the BSD sum algorithm, use 1K blocks (default)") .help(get_message("sum-help-bsd-compatible"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::SYSTEM_V_COMPATIBLE) Arg::new(options::SYSTEM_V_COMPATIBLE)
.short('s') .short('s')
.long(options::SYSTEM_V_COMPATIBLE) .long(options::SYSTEM_V_COMPATIBLE)
.help("use System V sum algorithm, use 512 bytes blocks") .help(get_message("sum-help-sysv-compatible"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
} }