Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/uu/ptx/locales/en-US.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
30 changes: 30 additions & 0 deletions src/uu/ptx/locales/fr-FR.ftl
Original file line number Diff line number Diff line change
@@ -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 }
53 changes: 30 additions & 23 deletions src/uu/ptx/src/ptx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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),
}
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -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())]),
),
));
}
}
Expand All @@ -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(
Expand All @@ -812,89 +819,89 @@ 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),
)
.arg(
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),
)
.arg(
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),
)
.arg(
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),
)
.arg(
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),
)
.arg(
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"),
)
}
Loading