mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
l10n: port csplit for translation + add french
This commit is contained in:
parent
05eb7ee374
commit
7fe550afed
5 changed files with 91 additions and 23 deletions
|
@ -1,3 +1,29 @@
|
|||
csplit-about = Split a file into sections determined by context lines
|
||||
csplit-usage = csplit [OPTION]... FILE PATTERN...
|
||||
csplit-after-help = Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output.
|
||||
|
||||
# Help messages
|
||||
csplit-help-suffix-format = use sprintf FORMAT instead of %02d
|
||||
csplit-help-prefix = use PREFIX instead of 'xx'
|
||||
csplit-help-keep-files = do not remove output files on errors
|
||||
csplit-help-suppress-matched = suppress the lines matching PATTERN
|
||||
csplit-help-digits = use specified number of digits instead of 2
|
||||
csplit-help-quiet = do not print counts of output file sizes
|
||||
csplit-help-elide-empty-files = remove empty output files
|
||||
|
||||
# Error messages
|
||||
csplit-error-line-out-of-range = { $pattern }: line number out of range
|
||||
csplit-error-line-out-of-range-on-repetition = { $pattern }: line number out of range on repetition { $repetition }
|
||||
csplit-error-match-not-found = { $pattern }: match not found
|
||||
csplit-error-match-not-found-on-repetition = { $pattern }: match not found on repetition { $repetition }
|
||||
csplit-error-line-number-is-zero = 0: line number must be greater than zero
|
||||
csplit-error-line-number-smaller-than-previous = line number '{ $current }' is smaller than preceding line number, { $previous }
|
||||
csplit-error-invalid-pattern = { $pattern }: invalid pattern
|
||||
csplit-error-invalid-number = invalid number: { $number }
|
||||
csplit-error-suffix-format-incorrect = incorrect conversion specification in suffix
|
||||
csplit-error-suffix-format-too-many-percents = too many % conversion specifications in suffix
|
||||
csplit-error-not-regular-file = { $file } is not a regular file
|
||||
csplit-warning-line-number-same-as-previous = line number '{ $line_number }' is the same as preceding line number
|
||||
csplit-stream-not-utf8 = stream did not contain valid UTF-8
|
||||
csplit-read-error = read error
|
||||
csplit-write-split-not-created = trying to write to a split that was not created
|
||||
|
|
29
src/uu/csplit/locales/fr-FR.ftl
Normal file
29
src/uu/csplit/locales/fr-FR.ftl
Normal file
|
@ -0,0 +1,29 @@
|
|||
csplit-about = Diviser un fichier en sections déterminées par des lignes de contexte
|
||||
csplit-usage = csplit [OPTION]... FICHIER MOTIF...
|
||||
csplit-after-help = Sortir les morceaux de FICHIER séparés par MOTIF(S) dans les fichiers 'xx00', 'xx01', ..., et sortir le nombre d'octets de chaque morceau sur la sortie standard.
|
||||
|
||||
# Messages d'aide
|
||||
csplit-help-suffix-format = utiliser le FORMAT sprintf au lieu de %02d
|
||||
csplit-help-prefix = utiliser PRÉFIXE au lieu de 'xx'
|
||||
csplit-help-keep-files = ne pas supprimer les fichiers de sortie en cas d'erreurs
|
||||
csplit-help-suppress-matched = supprimer les lignes correspondant au MOTIF
|
||||
csplit-help-digits = utiliser le nombre spécifié de chiffres au lieu de 2
|
||||
csplit-help-quiet = ne pas afficher le nombre d'octets des fichiers de sortie
|
||||
csplit-help-elide-empty-files = supprimer les fichiers de sortie vides
|
||||
|
||||
# Messages d'erreur
|
||||
csplit-error-line-out-of-range = { $pattern } : numéro de ligne hors limites
|
||||
csplit-error-line-out-of-range-on-repetition = { $pattern } : numéro de ligne hors limites à la répétition { $repetition }
|
||||
csplit-error-match-not-found = { $pattern } : correspondance non trouvée
|
||||
csplit-error-match-not-found-on-repetition = { $pattern } : correspondance non trouvée à la répétition { $repetition }
|
||||
csplit-error-line-number-is-zero = 0 : le numéro de ligne doit être supérieur à zéro
|
||||
csplit-error-line-number-smaller-than-previous = le numéro de ligne '{ $current }' est plus petit que le numéro de ligne précédent, { $previous }
|
||||
csplit-error-invalid-pattern = { $pattern } : motif invalide
|
||||
csplit-error-invalid-number = nombre invalide : { $number }
|
||||
csplit-error-suffix-format-incorrect = spécification de conversion incorrecte dans le suffixe
|
||||
csplit-error-suffix-format-too-many-percents = trop de spécifications de conversion % dans le suffixe
|
||||
csplit-error-not-regular-file = { $file } n'est pas un fichier régulier
|
||||
csplit-warning-line-number-same-as-previous = le numéro de ligne '{ $line_number }' est identique au numéro de ligne précédent
|
||||
csplit-stream-not-utf8 = le flux ne contenait pas d'UTF-8 valide
|
||||
csplit-read-error = erreur de lecture
|
||||
csplit-write-split-not-created = tentative d'écriture dans une division qui n'a pas été créée
|
|
@ -85,7 +85,10 @@ impl<T: BufRead> Iterator for LinesWithNewlines<T> {
|
|||
fn next(&mut self) -> Option<Self::Item> {
|
||||
fn ret(v: Vec<u8>) -> io::Result<String> {
|
||||
String::from_utf8(v).map_err(|_| {
|
||||
io::Error::new(ErrorKind::InvalidData, "stream did not contain valid UTF-8")
|
||||
io::Error::new(
|
||||
ErrorKind::InvalidData,
|
||||
get_message("csplit-stream-not-utf8"),
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -115,7 +118,7 @@ where
|
|||
T: BufRead,
|
||||
{
|
||||
let enumerated_input_lines = LinesWithNewlines::new(input)
|
||||
.map(|line| line.map_err_context(|| "read error".to_string()))
|
||||
.map(|line| line.map_err_context(|| get_message("csplit-read-error")))
|
||||
.enumerate();
|
||||
let mut input_iter = InputSplitter::new(enumerated_input_lines);
|
||||
let mut split_writer = SplitWriter::new(options);
|
||||
|
@ -283,7 +286,7 @@ impl SplitWriter<'_> {
|
|||
current_writer.write_all(bytes)?;
|
||||
self.size += bytes.len();
|
||||
}
|
||||
None => panic!("trying to write to a split that was not created"),
|
||||
None => panic!("{}", get_message("csplit-write-split-not-created")),
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -638,26 +641,26 @@ pub fn uu_app() -> Command {
|
|||
.short('b')
|
||||
.long(options::SUFFIX_FORMAT)
|
||||
.value_name("FORMAT")
|
||||
.help("use sprintf FORMAT instead of %02d"),
|
||||
.help(get_message("csplit-help-suffix-format")),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::PREFIX)
|
||||
.short('f')
|
||||
.long(options::PREFIX)
|
||||
.value_name("PREFIX")
|
||||
.help("use PREFIX instead of 'xx'"),
|
||||
.help(get_message("csplit-help-prefix")),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::KEEP_FILES)
|
||||
.short('k')
|
||||
.long(options::KEEP_FILES)
|
||||
.help("do not remove output files on errors")
|
||||
.help(get_message("csplit-help-keep-files"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::SUPPRESS_MATCHED)
|
||||
.long(options::SUPPRESS_MATCHED)
|
||||
.help("suppress the lines matching PATTERN")
|
||||
.help(get_message("csplit-help-suppress-matched"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
|
@ -665,7 +668,7 @@ pub fn uu_app() -> Command {
|
|||
.short('n')
|
||||
.long(options::DIGITS)
|
||||
.value_name("DIGITS")
|
||||
.help("use specified number of digits instead of 2"),
|
||||
.help(get_message("csplit-help-digits")),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::QUIET)
|
||||
|
@ -673,14 +676,14 @@ pub fn uu_app() -> Command {
|
|||
.long(options::QUIET)
|
||||
.visible_short_alias('s')
|
||||
.visible_alias("silent")
|
||||
.help("do not print counts of output file sizes")
|
||||
.help(get_message("csplit-help-quiet"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
Arg::new(options::ELIDE_EMPTY_FILES)
|
||||
.short('z')
|
||||
.long(options::ELIDE_EMPTY_FILES)
|
||||
.help("remove empty output files")
|
||||
.help(get_message("csplit-help-elide-empty-files"))
|
||||
.action(ArgAction::SetTrue),
|
||||
)
|
||||
.arg(
|
||||
|
|
|
@ -2,38 +2,40 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::io;
|
||||
use thiserror::Error;
|
||||
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::UError;
|
||||
use uucore::locale::{get_message, get_message_with_args};
|
||||
|
||||
/// Errors thrown by the csplit command
|
||||
#[derive(Debug, Error)]
|
||||
pub enum CsplitError {
|
||||
#[error("IO error: {}", _0)]
|
||||
IoError(#[from] io::Error),
|
||||
#[error("{}: line number out of range", ._0.quote())]
|
||||
#[error("{}", get_message_with_args("csplit-error-line-out-of-range", HashMap::from([("pattern".to_string(), _0.quote().to_string())])))]
|
||||
LineOutOfRange(String),
|
||||
#[error("{}: line number out of range on repetition {}", ._0.quote(), _1)]
|
||||
#[error("{}", get_message_with_args("csplit-error-line-out-of-range-on-repetition", HashMap::from([("pattern".to_string(), _0.quote().to_string()), ("repetition".to_string(), _1.to_string())])))]
|
||||
LineOutOfRangeOnRepetition(String, usize),
|
||||
#[error("{}: match not found", ._0.quote())]
|
||||
#[error("{}", get_message_with_args("csplit-error-match-not-found", HashMap::from([("pattern".to_string(), _0.quote().to_string())])))]
|
||||
MatchNotFound(String),
|
||||
#[error("{}: match not found on repetition {}", ._0.quote(), _1)]
|
||||
#[error("{}", get_message_with_args("csplit-error-match-not-found-on-repetition", HashMap::from([("pattern".to_string(), _0.quote().to_string()), ("repetition".to_string(), _1.to_string())])))]
|
||||
MatchNotFoundOnRepetition(String, usize),
|
||||
#[error("0: line number must be greater than zero")]
|
||||
#[error("{}", get_message("csplit-error-line-number-is-zero"))]
|
||||
LineNumberIsZero,
|
||||
#[error("line number '{}' is smaller than preceding line number, {}", _0, _1)]
|
||||
#[error("{}", get_message_with_args("csplit-error-line-number-smaller-than-previous", HashMap::from([("current".to_string(), _0.to_string()), ("previous".to_string(), _1.to_string())])))]
|
||||
LineNumberSmallerThanPrevious(usize, usize),
|
||||
#[error("{}: invalid pattern", ._0.quote())]
|
||||
#[error("{}", get_message_with_args("csplit-error-invalid-pattern", HashMap::from([("pattern".to_string(), _0.quote().to_string())])))]
|
||||
InvalidPattern(String),
|
||||
#[error("invalid number: {}", ._0.quote())]
|
||||
#[error("{}", get_message_with_args("csplit-error-invalid-number", HashMap::from([("number".to_string(), _0.quote().to_string())])))]
|
||||
InvalidNumber(String),
|
||||
#[error("incorrect conversion specification in suffix")]
|
||||
#[error("{}", get_message("csplit-error-suffix-format-incorrect"))]
|
||||
SuffixFormatIncorrect,
|
||||
#[error("too many % conversion specifications in suffix")]
|
||||
#[error("{}", get_message("csplit-error-suffix-format-too-many-percents"))]
|
||||
SuffixFormatTooManyPercents,
|
||||
#[error("{} is not a regular file", ._0.quote())]
|
||||
#[error("{}", get_message_with_args("csplit-error-not-regular-file", HashMap::from([("file".to_string(), _0.quote().to_string())])))]
|
||||
NotRegularFile(String),
|
||||
#[error("{}", _0)]
|
||||
UError(Box<dyn UError>),
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
use crate::csplit_error::CsplitError;
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use uucore::locale::get_message_with_args;
|
||||
use uucore::show_warning;
|
||||
|
||||
/// The definition of a pattern to match on a line.
|
||||
|
@ -168,7 +170,13 @@ fn validate_line_numbers(patterns: &[Pattern]) -> Result<(), CsplitError> {
|
|||
(_, 0) => Err(CsplitError::LineNumberIsZero),
|
||||
// two consecutive numbers should not be equal
|
||||
(n, m) if n == m => {
|
||||
show_warning!("line number '{n}' is the same as preceding line number");
|
||||
show_warning!(
|
||||
"{}",
|
||||
get_message_with_args(
|
||||
"csplit-warning-line-number-same-as-previous",
|
||||
HashMap::from([("line_number".to_string(), n.to_string())])
|
||||
)
|
||||
);
|
||||
Ok(n)
|
||||
}
|
||||
// a number cannot be greater than the one that follows
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue