Skip to content

Commit 813bb1f

Browse files
committed
l10n: port ptx for translation + add french
1 parent f825409 commit 813bb1f

File tree

3 files changed

+84
-23
lines changed

3 files changed

+84
-23
lines changed

src/uu/ptx/locales/en-US.ftl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,27 @@ ptx-about = Produce a permuted index of file contents
44
With no FILE, or when FILE is -, read standard input. Default is '-F /'.
55
ptx-usage = ptx [OPTION]... [INPUT]...
66
ptx -G [OPTION]... [INPUT [OUTPUT]]
7+
8+
# Help messages
9+
ptx-help-auto-reference = output automatically generated references
10+
ptx-help-traditional = behave more like System V 'ptx'
11+
ptx-help-flag-truncation = use STRING for flagging line truncations
12+
ptx-help-macro-name = macro name to use instead of 'xx'
13+
ptx-help-roff = generate output as roff directives
14+
ptx-help-tex = generate output as TeX directives
15+
ptx-help-right-side-refs = put references at right, not counted in -w
16+
ptx-help-sentence-regexp = for end of lines or end of sentences
17+
ptx-help-word-regexp = use REGEXP to match each keyword
18+
ptx-help-break-file = word break characters in this FILE
19+
ptx-help-ignore-case = fold lower case to upper case for sorting
20+
ptx-help-gap-size = gap size in columns between output fields
21+
ptx-help-ignore-file = read ignore word list from FILE
22+
ptx-help-only-file = read only word list from this FILE
23+
ptx-help-references = first field of each line is a reference
24+
ptx-help-width = output width in columns, reference excluded
25+
26+
# Error messages
27+
ptx-error-dumb-format = There is no dumb format with GNU extensions disabled
28+
ptx-error-not-implemented = { $feature } not implemented yet
29+
ptx-error-write-failed = write failed
30+
ptx-error-extra-operand = extra operand { $operand }

src/uu/ptx/locales/fr-FR.ftl

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

src/uu/ptx/src/ptx.rs

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ use thiserror::Error;
1818
use uucore::display::Quotable;
1919
use uucore::error::{FromIo, UError, UResult, UUsageError};
2020
use uucore::format_usage;
21-
22-
use uucore::locale::get_message;
21+
use uucore::locale::{get_message, get_message_with_args};
2322

2423
#[derive(Debug)]
2524
enum OutFormat {
@@ -196,10 +195,12 @@ struct WordRef {
196195

197196
#[derive(Debug, Error)]
198197
enum PtxError {
199-
#[error("There is no dumb format with GNU extensions disabled")]
198+
#[error("{}", get_message("ptx-error-dumb-format"))]
200199
DumbFormat,
201-
#[error("{0} not implemented yet")]
200+
201+
#[error("{}", get_message_with_args("ptx-error-not-implemented", HashMap::from([("feature".to_string(), .0.to_string())])))]
202202
NotImplemented(&'static str),
203+
203204
#[error("{0}")]
204205
ParseError(ParseIntError),
205206
}
@@ -690,10 +691,13 @@ fn write_traditional_output(
690691
return Err(PtxError::DumbFormat.into());
691692
}
692693
};
693-
writeln!(writer, "{output_line}").map_err_context(|| "write failed".into())?;
694+
writeln!(writer, "{output_line}")
695+
.map_err_context(|| get_message("ptx-error-write-failed"))?;
694696
}
695697

696-
writer.flush().map_err_context(|| "write failed".into())?;
698+
writer
699+
.flush()
700+
.map_err_context(|| get_message("ptx-error-write-failed"))?;
697701

698702
Ok(())
699703
}
@@ -751,7 +755,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
751755
if let Some(file) = files.next() {
752756
return Err(UUsageError::new(
753757
1,
754-
format!("extra operand {}", file.quote()),
758+
get_message_with_args(
759+
"ptx-error-extra-operand",
760+
HashMap::from([("operand".to_string(), file.quote().to_string())]),
761+
),
755762
));
756763
}
757764
}
@@ -778,28 +785,28 @@ pub fn uu_app() -> Command {
778785
Arg::new(options::AUTO_REFERENCE)
779786
.short('A')
780787
.long(options::AUTO_REFERENCE)
781-
.help("output automatically generated references")
788+
.help(get_message("ptx-help-auto-reference"))
782789
.action(ArgAction::SetTrue),
783790
)
784791
.arg(
785792
Arg::new(options::TRADITIONAL)
786793
.short('G')
787794
.long(options::TRADITIONAL)
788-
.help("behave more like System V 'ptx'")
795+
.help(get_message("ptx-help-traditional"))
789796
.action(ArgAction::SetTrue),
790797
)
791798
.arg(
792799
Arg::new(options::FLAG_TRUNCATION)
793800
.short('F')
794801
.long(options::FLAG_TRUNCATION)
795-
.help("use STRING for flagging line truncations")
802+
.help(get_message("ptx-help-flag-truncation"))
796803
.value_name("STRING"),
797804
)
798805
.arg(
799806
Arg::new(options::MACRO_NAME)
800807
.short('M')
801808
.long(options::MACRO_NAME)
802-
.help("macro name to use instead of 'xx'")
809+
.help(get_message("ptx-help-macro-name"))
803810
.value_name("STRING"),
804811
)
805812
.arg(
@@ -812,89 +819,89 @@ pub fn uu_app() -> Command {
812819
.arg(
813820
Arg::new(options::format::ROFF)
814821
.short('O')
815-
.help("generate output as roff directives")
822+
.help(get_message("ptx-help-roff"))
816823
.overrides_with_all([options::FORMAT, options::format::ROFF, options::format::TEX])
817824
.action(ArgAction::SetTrue),
818825
)
819826
.arg(
820827
Arg::new(options::format::TEX)
821828
.short('T')
822-
.help("generate output as TeX directives")
829+
.help(get_message("ptx-help-tex"))
823830
.overrides_with_all([options::FORMAT, options::format::ROFF, options::format::TEX])
824831
.action(ArgAction::SetTrue),
825832
)
826833
.arg(
827834
Arg::new(options::RIGHT_SIDE_REFS)
828835
.short('R')
829836
.long(options::RIGHT_SIDE_REFS)
830-
.help("put references at right, not counted in -w")
837+
.help(get_message("ptx-help-right-side-refs"))
831838
.action(ArgAction::SetTrue),
832839
)
833840
.arg(
834841
Arg::new(options::SENTENCE_REGEXP)
835842
.short('S')
836843
.long(options::SENTENCE_REGEXP)
837-
.help("for end of lines or end of sentences")
844+
.help(get_message("ptx-help-sentence-regexp"))
838845
.value_name("REGEXP"),
839846
)
840847
.arg(
841848
Arg::new(options::WORD_REGEXP)
842849
.short('W')
843850
.long(options::WORD_REGEXP)
844-
.help("use REGEXP to match each keyword")
851+
.help(get_message("ptx-help-word-regexp"))
845852
.value_name("REGEXP"),
846853
)
847854
.arg(
848855
Arg::new(options::BREAK_FILE)
849856
.short('b')
850857
.long(options::BREAK_FILE)
851-
.help("word break characters in this FILE")
858+
.help(get_message("ptx-help-break-file"))
852859
.value_name("FILE")
853860
.value_hint(clap::ValueHint::FilePath),
854861
)
855862
.arg(
856863
Arg::new(options::IGNORE_CASE)
857864
.short('f')
858865
.long(options::IGNORE_CASE)
859-
.help("fold lower case to upper case for sorting")
866+
.help(get_message("ptx-help-ignore-case"))
860867
.action(ArgAction::SetTrue),
861868
)
862869
.arg(
863870
Arg::new(options::GAP_SIZE)
864871
.short('g')
865872
.long(options::GAP_SIZE)
866-
.help("gap size in columns between output fields")
873+
.help(get_message("ptx-help-gap-size"))
867874
.value_name("NUMBER"),
868875
)
869876
.arg(
870877
Arg::new(options::IGNORE_FILE)
871878
.short('i')
872879
.long(options::IGNORE_FILE)
873-
.help("read ignore word list from FILE")
880+
.help(get_message("ptx-help-ignore-file"))
874881
.value_name("FILE")
875882
.value_hint(clap::ValueHint::FilePath),
876883
)
877884
.arg(
878885
Arg::new(options::ONLY_FILE)
879886
.short('o')
880887
.long(options::ONLY_FILE)
881-
.help("read only word list from this FILE")
888+
.help(get_message("ptx-help-only-file"))
882889
.value_name("FILE")
883890
.value_hint(clap::ValueHint::FilePath),
884891
)
885892
.arg(
886893
Arg::new(options::REFERENCES)
887894
.short('r')
888895
.long(options::REFERENCES)
889-
.help("first field of each line is a reference")
896+
.help(get_message("ptx-help-references"))
890897
.value_name("FILE")
891898
.action(ArgAction::SetTrue),
892899
)
893900
.arg(
894901
Arg::new(options::WIDTH)
895902
.short('w')
896903
.long(options::WIDTH)
897-
.help("output width in columns, reference excluded")
904+
.help(get_message("ptx-help-width"))
898905
.value_name("NUMBER"),
899906
)
900907
}

0 commit comments

Comments
 (0)