@@ -18,8 +18,7 @@ use thiserror::Error;
18
18
use uucore:: display:: Quotable ;
19
19
use uucore:: error:: { FromIo , UError , UResult , UUsageError } ;
20
20
use uucore:: format_usage;
21
-
22
- use uucore:: locale:: get_message;
21
+ use uucore:: locale:: { get_message, get_message_with_args} ;
23
22
24
23
#[ derive( Debug ) ]
25
24
enum OutFormat {
@@ -196,10 +195,12 @@ struct WordRef {
196
195
197
196
#[ derive( Debug , Error ) ]
198
197
enum PtxError {
199
- #[ error( "There is no dumb format with GNU extensions disabled" ) ]
198
+ #[ error( "{}" , get_message ( "ptx-error- dumb- format" ) ) ]
200
199
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( ) ) ] ) ) ) ]
202
202
NotImplemented ( & ' static str ) ,
203
+
203
204
#[ error( "{0}" ) ]
204
205
ParseError ( ParseIntError ) ,
205
206
}
@@ -690,10 +691,13 @@ fn write_traditional_output(
690
691
return Err ( PtxError :: DumbFormat . into ( ) ) ;
691
692
}
692
693
} ;
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" ) ) ?;
694
696
}
695
697
696
- writer. flush ( ) . map_err_context ( || "write failed" . into ( ) ) ?;
698
+ writer
699
+ . flush ( )
700
+ . map_err_context ( || get_message ( "ptx-error-write-failed" ) ) ?;
697
701
698
702
Ok ( ( ) )
699
703
}
@@ -751,7 +755,10 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
751
755
if let Some ( file) = files. next ( ) {
752
756
return Err ( UUsageError :: new (
753
757
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
+ ) ,
755
762
) ) ;
756
763
}
757
764
}
@@ -778,28 +785,28 @@ pub fn uu_app() -> Command {
778
785
Arg :: new ( options:: AUTO_REFERENCE )
779
786
. short ( 'A' )
780
787
. long ( options:: AUTO_REFERENCE )
781
- . help ( "output automatically generated references" )
788
+ . help ( get_message ( "ptx-help-auto-reference" ) )
782
789
. action ( ArgAction :: SetTrue ) ,
783
790
)
784
791
. arg (
785
792
Arg :: new ( options:: TRADITIONAL )
786
793
. short ( 'G' )
787
794
. long ( options:: TRADITIONAL )
788
- . help ( "behave more like System V ' ptx'" )
795
+ . help ( get_message ( " ptx-help-traditional" ) )
789
796
. action ( ArgAction :: SetTrue ) ,
790
797
)
791
798
. arg (
792
799
Arg :: new ( options:: FLAG_TRUNCATION )
793
800
. short ( 'F' )
794
801
. long ( options:: FLAG_TRUNCATION )
795
- . help ( "use STRING for flagging line truncations" )
802
+ . help ( get_message ( "ptx-help-flag-truncation" ) )
796
803
. value_name ( "STRING" ) ,
797
804
)
798
805
. arg (
799
806
Arg :: new ( options:: MACRO_NAME )
800
807
. short ( 'M' )
801
808
. long ( options:: MACRO_NAME )
802
- . help ( " macro name to use instead of 'xx'" )
809
+ . help ( get_message ( "ptx-help- macro- name" ) )
803
810
. value_name ( "STRING" ) ,
804
811
)
805
812
. arg (
@@ -812,89 +819,89 @@ pub fn uu_app() -> Command {
812
819
. arg (
813
820
Arg :: new ( options:: format:: ROFF )
814
821
. short ( 'O' )
815
- . help ( "generate output as roff directives" )
822
+ . help ( get_message ( "ptx-help- roff" ) )
816
823
. overrides_with_all ( [ options:: FORMAT , options:: format:: ROFF , options:: format:: TEX ] )
817
824
. action ( ArgAction :: SetTrue ) ,
818
825
)
819
826
. arg (
820
827
Arg :: new ( options:: format:: TEX )
821
828
. short ( 'T' )
822
- . help ( "generate output as TeX directives" )
829
+ . help ( get_message ( "ptx-help-tex" ) )
823
830
. overrides_with_all ( [ options:: FORMAT , options:: format:: ROFF , options:: format:: TEX ] )
824
831
. action ( ArgAction :: SetTrue ) ,
825
832
)
826
833
. arg (
827
834
Arg :: new ( options:: RIGHT_SIDE_REFS )
828
835
. short ( 'R' )
829
836
. long ( options:: RIGHT_SIDE_REFS )
830
- . help ( "put references at right, not counted in -w" )
837
+ . help ( get_message ( "ptx-help- right-side-refs" ) )
831
838
. action ( ArgAction :: SetTrue ) ,
832
839
)
833
840
. arg (
834
841
Arg :: new ( options:: SENTENCE_REGEXP )
835
842
. short ( 'S' )
836
843
. long ( options:: SENTENCE_REGEXP )
837
- . help ( "for end of lines or end of sentences" )
844
+ . help ( get_message ( "ptx-help-sentence-regexp" ) )
838
845
. value_name ( "REGEXP" ) ,
839
846
)
840
847
. arg (
841
848
Arg :: new ( options:: WORD_REGEXP )
842
849
. short ( 'W' )
843
850
. long ( options:: WORD_REGEXP )
844
- . help ( "use REGEXP to match each keyword" )
851
+ . help ( get_message ( "ptx-help-word-regexp" ) )
845
852
. value_name ( "REGEXP" ) ,
846
853
)
847
854
. arg (
848
855
Arg :: new ( options:: BREAK_FILE )
849
856
. short ( 'b' )
850
857
. long ( options:: BREAK_FILE )
851
- . help ( "word break characters in this FILE" )
858
+ . help ( get_message ( "ptx-help- break-file" ) )
852
859
. value_name ( "FILE" )
853
860
. value_hint ( clap:: ValueHint :: FilePath ) ,
854
861
)
855
862
. arg (
856
863
Arg :: new ( options:: IGNORE_CASE )
857
864
. short ( 'f' )
858
865
. long ( options:: IGNORE_CASE )
859
- . help ( "fold lower case to upper case for sorting" )
866
+ . help ( get_message ( "ptx-help-ignore- case" ) )
860
867
. action ( ArgAction :: SetTrue ) ,
861
868
)
862
869
. arg (
863
870
Arg :: new ( options:: GAP_SIZE )
864
871
. short ( 'g' )
865
872
. long ( options:: GAP_SIZE )
866
- . help ( " gap size in columns between output fields" )
873
+ . help ( get_message ( "ptx-help- gap- size" ) )
867
874
. value_name ( "NUMBER" ) ,
868
875
)
869
876
. arg (
870
877
Arg :: new ( options:: IGNORE_FILE )
871
878
. short ( 'i' )
872
879
. long ( options:: IGNORE_FILE )
873
- . help ( "read ignore word list from FILE" )
880
+ . help ( get_message ( "ptx-help- ignore-file" ) )
874
881
. value_name ( "FILE" )
875
882
. value_hint ( clap:: ValueHint :: FilePath ) ,
876
883
)
877
884
. arg (
878
885
Arg :: new ( options:: ONLY_FILE )
879
886
. short ( 'o' )
880
887
. long ( options:: ONLY_FILE )
881
- . help ( "read only word list from this FILE" )
888
+ . help ( get_message ( "ptx-help- only-file" ) )
882
889
. value_name ( "FILE" )
883
890
. value_hint ( clap:: ValueHint :: FilePath ) ,
884
891
)
885
892
. arg (
886
893
Arg :: new ( options:: REFERENCES )
887
894
. short ( 'r' )
888
895
. long ( options:: REFERENCES )
889
- . help ( "first field of each line is a reference" )
896
+ . help ( get_message ( "ptx-help-references" ) )
890
897
. value_name ( "FILE" )
891
898
. action ( ArgAction :: SetTrue ) ,
892
899
)
893
900
. arg (
894
901
Arg :: new ( options:: WIDTH )
895
902
. short ( 'w' )
896
903
. long ( options:: WIDTH )
897
- . help ( "output width in columns, reference excluded" )
904
+ . help ( get_message ( "ptx-help- width" ) )
898
905
. value_name ( "NUMBER" ) ,
899
906
)
900
907
}
0 commit comments