diff --git a/src/uu/comm/locales/en-US.ftl b/src/uu/comm/locales/en-US.ftl index 56b67be37..1118c09bb 100644 --- a/src/uu/comm/locales/en-US.ftl +++ b/src/uu/comm/locales/en-US.ftl @@ -6,3 +6,22 @@ comm-about = Compare two sorted files line by line. lines unique to FILE1, column two contains lines unique to FILE2, and column three contains lines common to both files. 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 diff --git a/src/uu/comm/locales/fr-FR.ftl b/src/uu/comm/locales/fr-FR.ftl new file mode 100644 index 000000000..490a6be35 --- /dev/null +++ b/src/uu/comm/locales/fr-FR.ftl @@ -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 diff --git a/src/uu/comm/src/comm.rs b/src/uu/comm/src/comm.rs index d595b463d..a0e10b747 100644 --- a/src/uu/comm/src/comm.rs +++ b/src/uu/comm/src/comm.rs @@ -6,6 +6,7 @@ // spell-checker:ignore (ToDO) delim mkdelim pairable use std::cmp::Ordering; +use std::collections::HashMap; use std::fs::{File, metadata}; use std::io::{self, BufRead, BufReader, Read, Stdin, stdin}; use uucore::error::{FromIo, UResult, USimpleError}; @@ -15,7 +16,7 @@ use uucore::line_ending::LineEnding; use clap::{Arg, ArgAction, ArgMatches, Command}; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; mod options { pub const COLUMN_1: &str = "1"; @@ -103,8 +104,11 @@ impl OrderChecker { let is_ordered = current_line >= &self.last_line; if !is_ordered && !self.has_error { 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; } @@ -247,13 +251,16 @@ fn comm(a: &mut LineReader, b: &mut LineReader, delim: &str, opts: &ArgMatches) if opts.get_flag(options::TOTAL) { 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) { // Print the input error message once at the end if input_error { - eprintln!("comm: input is not in sorted order"); + eprintln!("{}", get_message("comm-error-input-not-sorted")); } Err(USimpleError::new(1, "")) } else { @@ -266,7 +273,7 @@ fn open_file(name: &str, line_ending: LineEnding) -> io::Result { Ok(LineReader::new(Input::Stdin(stdin()), line_ending)) } else { 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)?; 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". return Err(USimpleError::new( 1, - "multiple conflicting output delimiters specified", + get_message("comm-error-multiple-conflicting-delimiters"), )); } } @@ -320,25 +327,25 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::COLUMN_1) .short('1') - .help("suppress column 1 (lines unique to FILE1)") + .help(get_message("comm-help-column-1")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::COLUMN_2) .short('2') - .help("suppress column 2 (lines unique to FILE2)") + .help(get_message("comm-help-column-2")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::COLUMN_3) .short('3') - .help("suppress column 3 (lines that appear in both files)") + .help(get_message("comm-help-column-3")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::DELIMITER) .long(options::DELIMITER) - .help("separate columns with STR") + .help(get_message("comm-help-delimiter")) .value_name("STR") .default_value(options::DELIMITER_DEFAULT) .allow_hyphen_values(true) @@ -350,7 +357,7 @@ pub fn uu_app() -> Command { .long(options::ZERO_TERMINATED) .short('z') .overrides_with(options::ZERO_TERMINATED) - .help("line delimiter is NUL, not newline") + .help(get_message("comm-help-zero-terminated")) .action(ArgAction::SetTrue), ) .arg( @@ -366,19 +373,19 @@ pub fn uu_app() -> Command { .arg( Arg::new(options::TOTAL) .long(options::TOTAL) - .help("output a summary") + .help(get_message("comm-help-total")) .action(ArgAction::SetTrue), ) .arg( Arg::new(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), ) .arg( Arg::new(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) .conflicts_with(options::CHECK_ORDER), )