1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #8188 from sylvestre/l10n-ptx

l10n: port ptx for translation + add french
This commit is contained in:
Daniel Hofstetter 2025-06-23 14:37:06 +02:00 committed by GitHub
commit 9ccaa54465
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 84 additions and 23 deletions

View file

@ -4,3 +4,27 @@ ptx-about = Produce a permuted index of file contents
With no FILE, or when FILE is -, read standard input. Default is '-F /'.
ptx-usage = ptx [OPTION]... [INPUT]...
ptx -G [OPTION]... [INPUT [OUTPUT]]
# Help messages
ptx-help-auto-reference = output automatically generated references
ptx-help-traditional = behave more like System V 'ptx'
ptx-help-flag-truncation = use STRING for flagging line truncations
ptx-help-macro-name = macro name to use instead of 'xx'
ptx-help-roff = generate output as roff directives
ptx-help-tex = generate output as TeX directives
ptx-help-right-side-refs = put references at right, not counted in -w
ptx-help-sentence-regexp = for end of lines or end of sentences
ptx-help-word-regexp = use REGEXP to match each keyword
ptx-help-break-file = word break characters in this FILE
ptx-help-ignore-case = fold lower case to upper case for sorting
ptx-help-gap-size = gap size in columns between output fields
ptx-help-ignore-file = read ignore word list from FILE
ptx-help-only-file = read only word list from this FILE
ptx-help-references = first field of each line is a reference
ptx-help-width = output width in columns, reference excluded
# Error messages
ptx-error-dumb-format = There is no dumb format with GNU extensions disabled
ptx-error-not-implemented = { $feature } not implemented yet
ptx-error-write-failed = write failed
ptx-error-extra-operand = extra operand { $operand }

View file

@ -0,0 +1,30 @@
ptx-about = Produire un index permuté du contenu des fichiers
Sortir un index permuté, incluant le contexte, des mots dans les fichiers d'entrée.
Les arguments obligatoires pour les options longues le sont aussi pour les options courtes.
Sans FICHIER, ou quand FICHIER est -, lire l'entrée standard. Par défaut c'est '-F /'.
ptx-usage = ptx [OPTION]... [ENTRÉE]...
ptx -G [OPTION]... [ENTRÉE [SORTIE]]
# Messages d'aide
ptx-help-auto-reference = sortir les références générées automatiquement
ptx-help-traditional = se comporter plus comme le 'ptx' de System V
ptx-help-flag-truncation = utiliser CHAÎNE pour marquer les troncatures de ligne
ptx-help-macro-name = nom de macro à utiliser au lieu de 'xx'
ptx-help-roff = générer la sortie comme directives roff
ptx-help-tex = générer la sortie comme directives TeX
ptx-help-right-side-refs = mettre les références à droite, non comptées dans -w
ptx-help-sentence-regexp = pour la fin de lignes ou la fin de phrases
ptx-help-word-regexp = utiliser REGEXP pour correspondre à chaque mot-clé
ptx-help-break-file = caractères de coupure de mots dans ce FICHIER
ptx-help-ignore-case = replier les minuscules en majuscules pour le tri
ptx-help-gap-size = taille de l'écart en colonnes entre les champs de sortie
ptx-help-ignore-file = lire la liste de mots à ignorer depuis FICHIER
ptx-help-only-file = lire seulement la liste de mots depuis ce FICHIER
ptx-help-references = le premier champ de chaque ligne est une référence
ptx-help-width = largeur de sortie en colonnes, référence exclue
# Messages d'erreur
ptx-error-dumb-format = Il n'y a pas de format simple avec les extensions GNU désactivées
ptx-error-not-implemented = { $feature } pas encore implémenté
ptx-error-write-failed = échec de l'écriture
ptx-error-extra-operand = opérande supplémentaire { $operand }

View file

@ -18,8 +18,7 @@ use thiserror::Error;
use uucore::display::Quotable;
use uucore::error::{FromIo, UError, UResult, UUsageError};
use uucore::format_usage;
use uucore::locale::get_message;
use uucore::locale::{get_message, get_message_with_args};
#[derive(Debug)]
enum OutFormat {
@ -196,10 +195,12 @@ struct WordRef {
#[derive(Debug, Error)]
enum PtxError {
#[error("There is no dumb format with GNU extensions disabled")]
#[error("{}", get_message("ptx-error-dumb-format"))]
DumbFormat,
#[error("{0} not implemented yet")]
#[error("{}", get_message_with_args("ptx-error-not-implemented", HashMap::from([("feature".to_string(), .0.to_string())])))]
NotImplemented(&'static str),
#[error("{0}")]
ParseError(ParseIntError),
}
@ -690,10 +691,13 @@ fn write_traditional_output(
return Err(PtxError::DumbFormat.into());
}
};
writeln!(writer, "{output_line}").map_err_context(|| "write failed".into())?;
writeln!(writer, "{output_line}")
.map_err_context(|| get_message("ptx-error-write-failed"))?;
}
writer.flush().map_err_context(|| "write failed".into())?;
writer
.flush()
.map_err_context(|| get_message("ptx-error-write-failed"))?;
Ok(())
}
@ -751,7 +755,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
if let Some(file) = files.next() {
return Err(UUsageError::new(
1,
format!("extra operand {}", file.quote()),
get_message_with_args(
"ptx-error-extra-operand",
HashMap::from([("operand".to_string(), file.quote().to_string())]),
),
));
}
}
@ -778,28 +785,28 @@ pub fn uu_app() -> Command {
Arg::new(options::AUTO_REFERENCE)
.short('A')
.long(options::AUTO_REFERENCE)
.help("output automatically generated references")
.help(get_message("ptx-help-auto-reference"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::TRADITIONAL)
.short('G')
.long(options::TRADITIONAL)
.help("behave more like System V 'ptx'")
.help(get_message("ptx-help-traditional"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::FLAG_TRUNCATION)
.short('F')
.long(options::FLAG_TRUNCATION)
.help("use STRING for flagging line truncations")
.help(get_message("ptx-help-flag-truncation"))
.value_name("STRING"),
)
.arg(
Arg::new(options::MACRO_NAME)
.short('M')
.long(options::MACRO_NAME)
.help("macro name to use instead of 'xx'")
.help(get_message("ptx-help-macro-name"))
.value_name("STRING"),
)
.arg(
@ -812,14 +819,14 @@ pub fn uu_app() -> Command {
.arg(
Arg::new(options::format::ROFF)
.short('O')
.help("generate output as roff directives")
.help(get_message("ptx-help-roff"))
.overrides_with_all([options::FORMAT, options::format::ROFF, options::format::TEX])
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::format::TEX)
.short('T')
.help("generate output as TeX directives")
.help(get_message("ptx-help-tex"))
.overrides_with_all([options::FORMAT, options::format::ROFF, options::format::TEX])
.action(ArgAction::SetTrue),
)
@ -827,28 +834,28 @@ pub fn uu_app() -> Command {
Arg::new(options::RIGHT_SIDE_REFS)
.short('R')
.long(options::RIGHT_SIDE_REFS)
.help("put references at right, not counted in -w")
.help(get_message("ptx-help-right-side-refs"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::SENTENCE_REGEXP)
.short('S')
.long(options::SENTENCE_REGEXP)
.help("for end of lines or end of sentences")
.help(get_message("ptx-help-sentence-regexp"))
.value_name("REGEXP"),
)
.arg(
Arg::new(options::WORD_REGEXP)
.short('W')
.long(options::WORD_REGEXP)
.help("use REGEXP to match each keyword")
.help(get_message("ptx-help-word-regexp"))
.value_name("REGEXP"),
)
.arg(
Arg::new(options::BREAK_FILE)
.short('b')
.long(options::BREAK_FILE)
.help("word break characters in this FILE")
.help(get_message("ptx-help-break-file"))
.value_name("FILE")
.value_hint(clap::ValueHint::FilePath),
)
@ -856,21 +863,21 @@ pub fn uu_app() -> Command {
Arg::new(options::IGNORE_CASE)
.short('f')
.long(options::IGNORE_CASE)
.help("fold lower case to upper case for sorting")
.help(get_message("ptx-help-ignore-case"))
.action(ArgAction::SetTrue),
)
.arg(
Arg::new(options::GAP_SIZE)
.short('g')
.long(options::GAP_SIZE)
.help("gap size in columns between output fields")
.help(get_message("ptx-help-gap-size"))
.value_name("NUMBER"),
)
.arg(
Arg::new(options::IGNORE_FILE)
.short('i')
.long(options::IGNORE_FILE)
.help("read ignore word list from FILE")
.help(get_message("ptx-help-ignore-file"))
.value_name("FILE")
.value_hint(clap::ValueHint::FilePath),
)
@ -878,7 +885,7 @@ pub fn uu_app() -> Command {
Arg::new(options::ONLY_FILE)
.short('o')
.long(options::ONLY_FILE)
.help("read only word list from this FILE")
.help(get_message("ptx-help-only-file"))
.value_name("FILE")
.value_hint(clap::ValueHint::FilePath),
)
@ -886,7 +893,7 @@ pub fn uu_app() -> Command {
Arg::new(options::REFERENCES)
.short('r')
.long(options::REFERENCES)
.help("first field of each line is a reference")
.help(get_message("ptx-help-references"))
.value_name("FILE")
.action(ArgAction::SetTrue),
)
@ -894,7 +901,7 @@ pub fn uu_app() -> Command {
Arg::new(options::WIDTH)
.short('w')
.long(options::WIDTH)
.help("output width in columns, reference excluded")
.help(get_message("ptx-help-width"))
.value_name("NUMBER"),
)
}