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

l10n: port comm for translation + add french

This commit is contained in:
Sylvestre Ledru 2025-06-13 23:20:30 +02:00
parent c9f76d41a7
commit e9c58cdbe0
3 changed files with 68 additions and 15 deletions

View file

@ -6,3 +6,22 @@ comm-about = Compare two sorted files line by line.
lines unique to FILE1, column two contains lines unique to FILE2, lines unique to FILE1, column two contains lines unique to FILE2,
and column three contains lines common to both files. and column three contains lines common to both files.
comm-usage = comm [OPTION]... FILE1 FILE2 comm-usage = comm [OPTION]... FILE1 FILE2
# Help messages
comm-help-column-1 = suppress column 1 (lines unique to FILE1)
comm-help-column-2 = suppress column 2 (lines unique to FILE2)
comm-help-column-3 = suppress column 3 (lines that appear in both files)
comm-help-delimiter = separate columns with STR
comm-help-zero-terminated = line delimiter is NUL, not newline
comm-help-total = output a summary
comm-help-check-order = check that the input is correctly sorted, even if all input lines are pairable
comm-help-no-check-order = do not check that the input is correctly sorted
# Error messages
comm-error-file-not-sorted = comm: file { $file_num } is not in sorted order
comm-error-input-not-sorted = comm: input is not in sorted order
comm-error-is-directory = Is a directory
comm-error-multiple-conflicting-delimiters = multiple conflicting output delimiters specified
# Other messages
comm-total = total

View file

@ -0,0 +1,27 @@
comm-about = Comparer deux fichiers triés ligne par ligne.
Lorsque FICHIER1 ou FICHIER2 (pas les deux) est -, lire l'entrée standard.
Sans options, produit une sortie à trois colonnes. La colonne un contient
les lignes uniques à FICHIER1, la colonne deux contient les lignes uniques à FICHIER2,
et la colonne trois contient les lignes communes aux deux fichiers.
comm-usage = comm [OPTION]... FICHIER1 FICHIER2
# Messages d'aide
comm-help-column-1 = supprimer la colonne 1 (lignes uniques à FICHIER1)
comm-help-column-2 = supprimer la colonne 2 (lignes uniques à FICHIER2)
comm-help-column-3 = supprimer la colonne 3 (lignes qui apparaissent dans les deux fichiers)
comm-help-delimiter = séparer les colonnes avec STR
comm-help-zero-terminated = le délimiteur de ligne est NUL, pas nouvelle ligne
comm-help-total = afficher un résumé
comm-help-check-order = vérifier que l'entrée est correctement triée, même si toutes les lignes d'entrée sont appariables
comm-help-no-check-order = ne pas vérifier que l'entrée est correctement triée
# Messages d'erreur
comm-error-file-not-sorted = comm : le fichier { $file_num } n'est pas dans l'ordre trié
comm-error-input-not-sorted = comm : l'entrée n'est pas dans l'ordre trié
comm-error-is-directory = Est un répertoire
comm-error-multiple-conflicting-delimiters = plusieurs délimiteurs de sortie en conflit spécifiés
# Autres messages
comm-total = total

View file

@ -6,6 +6,7 @@
// spell-checker:ignore (ToDO) delim mkdelim pairable // spell-checker:ignore (ToDO) delim mkdelim pairable
use std::cmp::Ordering; use std::cmp::Ordering;
use std::collections::HashMap;
use std::fs::{File, metadata}; use std::fs::{File, metadata};
use std::io::{self, BufRead, BufReader, Read, Stdin, stdin}; use std::io::{self, BufRead, BufReader, Read, Stdin, stdin};
use uucore::error::{FromIo, UResult, USimpleError}; use uucore::error::{FromIo, UResult, USimpleError};
@ -15,7 +16,7 @@ use uucore::line_ending::LineEnding;
use clap::{Arg, ArgAction, ArgMatches, Command}; use clap::{Arg, ArgAction, ArgMatches, Command};
use uucore::locale::get_message; use uucore::locale::{get_message, get_message_with_args};
mod options { mod options {
pub const COLUMN_1: &str = "1"; pub const COLUMN_1: &str = "1";
@ -103,8 +104,11 @@ impl OrderChecker {
let is_ordered = current_line >= &self.last_line; let is_ordered = current_line >= &self.last_line;
if !is_ordered && !self.has_error { if !is_ordered && !self.has_error {
eprintln!( eprintln!(
"comm: file {} is not in sorted order", "{}",
self.file_num.as_str() get_message_with_args(
"comm-error-file-not-sorted",
HashMap::from([("file_num".to_string(), self.file_num.as_str().to_string())])
)
); );
self.has_error = true; self.has_error = true;
} }
@ -247,13 +251,16 @@ fn comm(a: &mut LineReader, b: &mut LineReader, delim: &str, opts: &ArgMatches)
if opts.get_flag(options::TOTAL) { if opts.get_flag(options::TOTAL) {
let line_ending = LineEnding::from_zero_flag(opts.get_flag(options::ZERO_TERMINATED)); let line_ending = LineEnding::from_zero_flag(opts.get_flag(options::ZERO_TERMINATED));
print!("{total_col_1}{delim}{total_col_2}{delim}{total_col_3}{delim}total{line_ending}"); print!(
"{total_col_1}{delim}{total_col_2}{delim}{total_col_3}{delim}{}{line_ending}",
get_message("comm-total")
);
} }
if should_check_order && (checker1.has_error || checker2.has_error) { if should_check_order && (checker1.has_error || checker2.has_error) {
// Print the input error message once at the end // Print the input error message once at the end
if input_error { if input_error {
eprintln!("comm: input is not in sorted order"); eprintln!("{}", get_message("comm-error-input-not-sorted"));
} }
Err(USimpleError::new(1, "")) Err(USimpleError::new(1, ""))
} else { } else {
@ -266,7 +273,7 @@ fn open_file(name: &str, line_ending: LineEnding) -> io::Result<LineReader> {
Ok(LineReader::new(Input::Stdin(stdin()), line_ending)) Ok(LineReader::new(Input::Stdin(stdin()), line_ending))
} else { } else {
if metadata(name)?.is_dir() { if metadata(name)?.is_dir() {
return Err(io::Error::other("Is a directory")); return Err(io::Error::other(get_message("comm-error-is-directory")));
} }
let f = File::open(name)?; let f = File::open(name)?;
Ok(LineReader::new( Ok(LineReader::new(
@ -298,7 +305,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
// Note: This intentionally deviate from the GNU error message by inserting the word "conflicting". // Note: This intentionally deviate from the GNU error message by inserting the word "conflicting".
return Err(USimpleError::new( return Err(USimpleError::new(
1, 1,
"multiple conflicting output delimiters specified", get_message("comm-error-multiple-conflicting-delimiters"),
)); ));
} }
} }
@ -320,25 +327,25 @@ pub fn uu_app() -> Command {
.arg( .arg(
Arg::new(options::COLUMN_1) Arg::new(options::COLUMN_1)
.short('1') .short('1')
.help("suppress column 1 (lines unique to FILE1)") .help(get_message("comm-help-column-1"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::COLUMN_2) Arg::new(options::COLUMN_2)
.short('2') .short('2')
.help("suppress column 2 (lines unique to FILE2)") .help(get_message("comm-help-column-2"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::COLUMN_3) Arg::new(options::COLUMN_3)
.short('3') .short('3')
.help("suppress column 3 (lines that appear in both files)") .help(get_message("comm-help-column-3"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::DELIMITER) Arg::new(options::DELIMITER)
.long(options::DELIMITER) .long(options::DELIMITER)
.help("separate columns with STR") .help(get_message("comm-help-delimiter"))
.value_name("STR") .value_name("STR")
.default_value(options::DELIMITER_DEFAULT) .default_value(options::DELIMITER_DEFAULT)
.allow_hyphen_values(true) .allow_hyphen_values(true)
@ -350,7 +357,7 @@ pub fn uu_app() -> Command {
.long(options::ZERO_TERMINATED) .long(options::ZERO_TERMINATED)
.short('z') .short('z')
.overrides_with(options::ZERO_TERMINATED) .overrides_with(options::ZERO_TERMINATED)
.help("line delimiter is NUL, not newline") .help(get_message("comm-help-zero-terminated"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
@ -366,19 +373,19 @@ pub fn uu_app() -> Command {
.arg( .arg(
Arg::new(options::TOTAL) Arg::new(options::TOTAL)
.long(options::TOTAL) .long(options::TOTAL)
.help("output a summary") .help(get_message("comm-help-total"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::CHECK_ORDER) Arg::new(options::CHECK_ORDER)
.long(options::CHECK_ORDER) .long(options::CHECK_ORDER)
.help("check that the input is correctly sorted, even if all input lines are pairable") .help(get_message("comm-help-check-order"))
.action(ArgAction::SetTrue), .action(ArgAction::SetTrue),
) )
.arg( .arg(
Arg::new(options::NO_CHECK_ORDER) Arg::new(options::NO_CHECK_ORDER)
.long(options::NO_CHECK_ORDER) .long(options::NO_CHECK_ORDER)
.help("do not check that the input is correctly sorted") .help(get_message("comm-help-no-check-order"))
.action(ArgAction::SetTrue) .action(ArgAction::SetTrue)
.conflicts_with(options::CHECK_ORDER), .conflicts_with(options::CHECK_ORDER),
) )