mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
Merge pull request #8100 from sylvestre/l10n-fold
l10n: port fold to translation + add french
This commit is contained in:
commit
40c9ab944e
3 changed files with 27 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
||||||
fold-about = Writes each file (or standard input if no files are given)
|
fold-about = Writes each file (or standard input if no files are given)
|
||||||
to standard output whilst breaking long lines
|
to standard output whilst breaking long lines
|
||||||
fold-usage = fold [OPTION]... [FILE]...
|
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
|
||||||
|
|
7
src/uu/fold/locales/fr-FR.ftl
Normal file
7
src/uu/fold/locales/fr-FR.ftl
Normal file
|
@ -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
|
|
@ -6,13 +6,14 @@
|
||||||
// spell-checker:ignore (ToDOs) ncount routput
|
// spell-checker:ignore (ToDOs) ncount routput
|
||||||
|
|
||||||
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::{BufRead, BufReader, Read, stdin};
|
use std::io::{BufRead, BufReader, Read, stdin};
|
||||||
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::format_usage;
|
use uucore::format_usage;
|
||||||
use uucore::locale::get_message;
|
use uucore::locale::{get_message, get_message_with_args};
|
||||||
|
|
||||||
const TAB_WIDTH: usize = 8;
|
const TAB_WIDTH: usize = 8;
|
||||||
|
|
||||||
|
@ -41,7 +42,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
Some(inp_width) => inp_width.parse::<usize>().map_err(|e| {
|
Some(inp_width) => inp_width.parse::<usize>().map_err(|e| {
|
||||||
USimpleError::new(
|
USimpleError::new(
|
||||||
1,
|
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,
|
None => 80,
|
||||||
|
@ -65,24 +72,21 @@ pub fn uu_app() -> Command {
|
||||||
Arg::new(options::BYTES)
|
Arg::new(options::BYTES)
|
||||||
.long(options::BYTES)
|
.long(options::BYTES)
|
||||||
.short('b')
|
.short('b')
|
||||||
.help(
|
.help(get_message("fold-bytes-help"))
|
||||||
"count using bytes rather than columns (meaning control characters \
|
|
||||||
such as newline are not treated specially)",
|
|
||||||
)
|
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::SPACES)
|
Arg::new(options::SPACES)
|
||||||
.long(options::SPACES)
|
.long(options::SPACES)
|
||||||
.short('s')
|
.short('s')
|
||||||
.help("break lines at word boundaries rather than a hard cut-off")
|
.help(get_message("fold-spaces-help"))
|
||||||
.action(ArgAction::SetTrue),
|
.action(ArgAction::SetTrue),
|
||||||
)
|
)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::new(options::WIDTH)
|
Arg::new(options::WIDTH)
|
||||||
.long(options::WIDTH)
|
.long(options::WIDTH)
|
||||||
.short('w')
|
.short('w')
|
||||||
.help("set WIDTH as the maximum line width rather than 80")
|
.help(get_message("fold-width-help"))
|
||||||
.value_name("WIDTH")
|
.value_name("WIDTH")
|
||||||
.allow_hyphen_values(true),
|
.allow_hyphen_values(true),
|
||||||
)
|
)
|
||||||
|
@ -142,7 +146,7 @@ fn fold_file_bytewise<T: Read>(mut file: BufReader<T>, spaces: bool, width: usiz
|
||||||
loop {
|
loop {
|
||||||
if file
|
if file
|
||||||
.read_line(&mut line)
|
.read_line(&mut line)
|
||||||
.map_err_context(|| "failed to read line".to_string())?
|
.map_err_context(|| get_message("fold-error-readline"))?
|
||||||
== 0
|
== 0
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -236,7 +240,7 @@ fn fold_file<T: Read>(mut file: BufReader<T>, spaces: bool, width: usize) -> URe
|
||||||
loop {
|
loop {
|
||||||
if file
|
if file
|
||||||
.read_line(&mut line)
|
.read_line(&mut line)
|
||||||
.map_err_context(|| "failed to read line".to_string())?
|
.map_err_context(|| get_message("fold-error-readline"))?
|
||||||
== 0
|
== 0
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -275,7 +279,7 @@ fn fold_file<T: Read>(mut file: BufReader<T>, spaces: bool, width: usize) -> URe
|
||||||
col_count += 1;
|
col_count += 1;
|
||||||
}
|
}
|
||||||
_ => col_count += 1,
|
_ => col_count += 1,
|
||||||
};
|
}
|
||||||
|
|
||||||
output.push(ch);
|
output.push(ch);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue