diff --git a/src/uu/fold/locales/en-US.ftl b/src/uu/fold/locales/en-US.ftl index 5d5bb40a6..9f8c6f3b9 100644 --- a/src/uu/fold/locales/en-US.ftl +++ b/src/uu/fold/locales/en-US.ftl @@ -1,3 +1,8 @@ fold-about = Writes each file (or standard input if no files are given) to standard output whilst breaking long lines fold-usage = fold [OPTION]... [FILE]... +fold-bytes-help = count using bytes rather than columns (meaning control characters such as newline are not treated specially) +fold-spaces-help = break lines at word boundaries rather than a hard cut-off +fold-width-help = set WIDTH as the maximum line width rather than 80 +fold-error-illegal-width = illegal width value +fold-error-readline = failed to read line diff --git a/src/uu/fold/locales/fr-FR.ftl b/src/uu/fold/locales/fr-FR.ftl new file mode 100644 index 000000000..1a7235940 --- /dev/null +++ b/src/uu/fold/locales/fr-FR.ftl @@ -0,0 +1,7 @@ +fold-about = Écrit chaque fichier (ou l'entrée standard si aucun fichier n'est donné) sur la sortie standard en coupant les lignes trop longues +fold-usage = fold [OPTION]... [FICHIER]... +fold-bytes-help = compter en octets plutôt qu'en colonnes (les caractères de contrôle comme retour chariot ne sont pas traités spécialement) +fold-spaces-help = couper les lignes aux limites de mots plutôt qu'à une largeur fixe +fold-width-help = définir WIDTH comme largeur de ligne maximale au lieu de 80 +fold-error-illegal-width = valeur de largeur illégale +fold-error-readline = échec de lecture de la ligne diff --git a/src/uu/fold/src/fold.rs b/src/uu/fold/src/fold.rs index 465f96433..abfc6fc56 100644 --- a/src/uu/fold/src/fold.rs +++ b/src/uu/fold/src/fold.rs @@ -6,13 +6,14 @@ // spell-checker:ignore (ToDOs) ncount routput use clap::{Arg, ArgAction, Command}; +use std::collections::HashMap; use std::fs::File; use std::io::{BufRead, BufReader, Read, stdin}; use std::path::Path; use uucore::display::Quotable; use uucore::error::{FromIo, UResult, USimpleError}; use uucore::format_usage; -use uucore::locale::get_message; +use uucore::locale::{get_message, get_message_with_args}; const TAB_WIDTH: usize = 8; @@ -41,7 +42,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { Some(inp_width) => inp_width.parse::().map_err(|e| { USimpleError::new( 1, - format!("illegal width value ({}): {e}", inp_width.quote()), + get_message_with_args( + "fold-error-illegal-width", + HashMap::from([ + ("width".to_string(), inp_width.quote().to_string()), + ("error".to_string(), e.to_string()), + ]), + ), ) })?, None => 80, @@ -65,24 +72,21 @@ pub fn uu_app() -> Command { Arg::new(options::BYTES) .long(options::BYTES) .short('b') - .help( - "count using bytes rather than columns (meaning control characters \ - such as newline are not treated specially)", - ) + .help(get_message("fold-bytes-help")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::SPACES) .long(options::SPACES) .short('s') - .help("break lines at word boundaries rather than a hard cut-off") + .help(get_message("fold-spaces-help")) .action(ArgAction::SetTrue), ) .arg( Arg::new(options::WIDTH) .long(options::WIDTH) .short('w') - .help("set WIDTH as the maximum line width rather than 80") + .help(get_message("fold-width-help")) .value_name("WIDTH") .allow_hyphen_values(true), ) @@ -142,7 +146,7 @@ fn fold_file_bytewise(mut file: BufReader, spaces: bool, width: usiz loop { if file .read_line(&mut line) - .map_err_context(|| "failed to read line".to_string())? + .map_err_context(|| get_message("fold-error-readline"))? == 0 { break; @@ -236,7 +240,7 @@ fn fold_file(mut file: BufReader, spaces: bool, width: usize) -> URe loop { if file .read_line(&mut line) - .map_err_context(|| "failed to read line".to_string())? + .map_err_context(|| get_message("fold-error-readline"))? == 0 { break; @@ -275,7 +279,7 @@ fn fold_file(mut file: BufReader, spaces: bool, width: usize) -> URe col_count += 1; } _ => col_count += 1, - }; + } output.push(ch); }