1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #8205 from sylvestre/l10n-expand

l10n: port expand for translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-18 10:51:48 +02:00 committed by GitHub
commit 2451682637
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 52 additions and 15 deletions

View file

@ -1,3 +1,18 @@
expand-about = Convert tabs in each FILE to spaces, writing to standard output. expand-about = Convert tabs in each FILE to spaces, writing to standard output.
With no FILE, or when FILE is -, read standard input. With no FILE, or when FILE is -, read standard input.
expand-usage = expand [OPTION]... [FILE]... expand-usage = expand [OPTION]... [FILE]...
# Help messages
expand-help-initial = do not convert tabs after non blanks
expand-help-tabs = have tabs N characters apart, not 8 or use comma separated list of explicit tab positions
expand-help-no-utf8 = interpret input file as 8-bit ASCII rather than UTF-8
# Error messages
expand-error-invalid-character = tab size contains invalid character(s): { $char }
expand-error-specifier-not-at-start = { $specifier } specifier not at start of number: { $number }
expand-error-specifier-only-allowed-with-last = { $specifier } specifier only allowed with the last value
expand-error-tab-size-cannot-be-zero = tab size cannot be 0
expand-error-tab-size-too-large = tab stop is too large { $size }
expand-error-tab-sizes-must-be-ascending = tab sizes must be ascending
expand-error-is-directory = { $file }: Is a directory
expand-error-failed-to-write-output = failed to write output

View file

@ -0,0 +1,18 @@
expand-about = Convertir les tabulations de chaque FICHIER en espaces, en écrivant vers la sortie standard.
Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard.
expand-usage = expand [OPTION]... [FICHIER]...
# Messages d'aide
expand-help-initial = ne pas convertir les tabulations après les caractères non-blancs
expand-help-tabs = avoir des tabulations espacées de N caractères, pas 8 ou utiliser une liste séparée par des virgules de positions de tabulation explicites
expand-help-no-utf8 = interpréter le fichier d'entrée comme ASCII 8 bits plutôt que UTF-8
# Messages d'erreur
expand-error-invalid-character = la taille de tabulation contient des caractères invalides : { $char }
expand-error-specifier-not-at-start = le spécificateur { $specifier } n'est pas au début du nombre : { $number }
expand-error-specifier-only-allowed-with-last = le spécificateur { $specifier } n'est autorisé qu'avec la dernière valeur
expand-error-tab-size-cannot-be-zero = la taille de tabulation ne peut pas être 0
expand-error-tab-size-too-large = l'arrêt de tabulation est trop grand { $size }
expand-error-tab-sizes-must-be-ascending = les tailles de tabulation doivent être croissantes
expand-error-is-directory = { $file } : Est un répertoire
expand-error-failed-to-write-output = échec de l'écriture de la sortie

View file

@ -6,6 +6,7 @@
// spell-checker:ignore (ToDO) ctype cwidth iflag nbytes nspaces nums tspaces uflag Preprocess // spell-checker:ignore (ToDO) ctype cwidth iflag nbytes nspaces nums tspaces uflag Preprocess
use clap::{Arg, ArgAction, ArgMatches, Command}; use clap::{Arg, ArgAction, ArgMatches, Command};
use std::collections::HashMap;
use std::ffi::OsString; use std::ffi::OsString;
use std::fs::File; use std::fs::File;
use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout}; use std::io::{BufRead, BufReader, BufWriter, Read, Write, stdin, stdout};
@ -18,7 +19,7 @@ use uucore::display::Quotable;
use uucore::error::{FromIo, UError, UResult, set_exit_code}; use uucore::error::{FromIo, UError, UResult, set_exit_code};
use uucore::{format_usage, show_error}; use uucore::{format_usage, show_error};
use uucore::locale::get_message; use uucore::locale::{get_message, get_message_with_args};
pub mod options { pub mod options {
pub static TABS: &str = "tabs"; pub static TABS: &str = "tabs";
@ -61,17 +62,17 @@ fn is_digit_or_comma(c: char) -> bool {
/// Errors that can occur when parsing a `--tabs` argument. /// Errors that can occur when parsing a `--tabs` argument.
#[derive(Debug, Error)] #[derive(Debug, Error)]
enum ParseError { enum ParseError {
#[error("tab size contains invalid character(s): {}", .0.quote())] #[error("{}", get_message_with_args("expand-error-invalid-character", HashMap::from([("char".to_string(), .0.quote().to_string())])))]
InvalidCharacter(String), InvalidCharacter(String),
#[error("{} specifier not at start of number: {}", .0.quote(), .1.quote())] #[error("{}", get_message_with_args("expand-error-specifier-not-at-start", HashMap::from([("specifier".to_string(), .0.quote().to_string()), ("number".to_string(), .1.quote().to_string())])))]
SpecifierNotAtStartOfNumber(String, String), SpecifierNotAtStartOfNumber(String, String),
#[error("{} specifier only allowed with the last value", .0.quote())] #[error("{}", get_message_with_args("expand-error-specifier-only-allowed-with-last", HashMap::from([("specifier".to_string(), .0.quote().to_string())])))]
SpecifierOnlyAllowedWithLastValue(String), SpecifierOnlyAllowedWithLastValue(String),
#[error("tab size cannot be 0")] #[error("{}", get_message("expand-error-tab-size-cannot-be-zero"))]
TabSizeCannotBeZero, TabSizeCannotBeZero,
#[error("tab stop is too large {}", .0.quote())] #[error("{}", get_message_with_args("expand-error-tab-size-too-large", HashMap::from([("size".to_string(), .0.quote().to_string())])))]
TabSizeTooLarge(String), TabSizeTooLarge(String),
#[error("tab sizes must be ascending")] #[error("{}", get_message("expand-error-tab-sizes-must-be-ascending"))]
TabSizesMustBeAscending, TabSizesMustBeAscending,
} }
@ -261,7 +262,7 @@ pub fn uu_app() -> Command {
Arg::new(options::INITIAL) Arg::new(options::INITIAL)
.long(options::INITIAL) .long(options::INITIAL)
.short('i') .short('i')
.help("do not convert tabs after non blanks") .help(get_message("expand-help-initial"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -270,16 +271,13 @@ pub fn uu_app() -> Command {
.short('t') .short('t')
.value_name("N, LIST") .value_name("N, LIST")
.action(ArgAction::Append) .action(ArgAction::Append)
.help( .help(get_message("expand-help-tabs")),
"have tabs N characters apart, not 8 or use comma separated list \
of explicit tab positions",
),
) )
.arg( .arg(
Arg::new(options::NO_UTF8) Arg::new(options::NO_UTF8)
.long(options::NO_UTF8) .long(options::NO_UTF8)
.short('U') .short('U')
.help("interpret input file as 8-bit ASCII rather than UTF-8") .help(get_message("expand-help-no-utf8"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -447,7 +445,13 @@ fn expand(options: &Options) -> UResult<()> {
for file in &options.files { for file in &options.files {
if Path::new(file).is_dir() { if Path::new(file).is_dir() {
show_error!("{file}: Is a directory"); show_error!(
"{}",
get_message_with_args(
"expand-error-is-directory",
HashMap::from([("file".to_string(), file.to_string())])
)
);
set_exit_code(1); set_exit_code(1);
continue; continue;
} }
@ -458,7 +462,7 @@ fn expand(options: &Options) -> UResult<()> {
Err(_) => buf.is_empty(), Err(_) => buf.is_empty(),
} { } {
expand_line(&mut buf, &mut output, ts, options) expand_line(&mut buf, &mut output, ts, options)
.map_err_context(|| "failed to write output".to_string())?; .map_err_context(|| get_message("expand-error-failed-to-write-output"))?;
} }
} }
Err(e) => { Err(e) => {