@@ -18,8 +18,7 @@ use thiserror::Error;
1818use uucore:: display:: Quotable ;
1919use uucore:: error:: { FromIo , UError , UResult , UUsageError } ;
2020use uucore:: format_usage;
21-
22- use uucore:: locale:: get_message;
21+ use uucore:: locale:: { get_message, get_message_with_args} ;
2322
2423#[ derive( Debug ) ]
2524enum OutFormat {
@@ -196,10 +195,12 @@ struct WordRef {
196195
197196#[ derive( Debug , Error ) ]
198197enum 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