66// spell-checker:ignore hexupper lsbf msbf unpadded nopad aGVsbG8sIHdvcmxkIQ
77
88use clap:: { Arg , ArgAction , Command } ;
9- use std:: collections:: HashMap ;
109use std:: fs:: File ;
1110use std:: io:: { self , ErrorKind , Read , Seek , SeekFrom } ;
1211use std:: path:: { Path , PathBuf } ;
@@ -18,7 +17,7 @@ use uucore::encoding::{
1817use uucore:: encoding:: { EncodingWrapper , SupportsFastDecodeAndEncode } ;
1918use uucore:: error:: { FromIo , UResult , USimpleError , UUsageError } ;
2019use uucore:: format_usage;
21- use uucore:: locale :: { get_message , get_message_with_args } ;
20+ use uucore:: translate ;
2221
2322pub const BASE_CMD_PARSE_ERROR : i32 = 1 ;
2423
@@ -52,10 +51,7 @@ impl Config {
5251 if let Some ( extra_op) = values. next ( ) {
5352 return Err ( UUsageError :: new (
5453 BASE_CMD_PARSE_ERROR ,
55- get_message_with_args (
56- "base-common-extra-operand" ,
57- HashMap :: from ( [ ( "operand" . to_string ( ) , extra_op. quote ( ) . to_string ( ) ) ] ) ,
58- ) ,
54+ translate ! ( "base-common-extra-operand" , "operand" => extra_op. quote( ) ) ,
5955 ) ) ;
6056 }
6157
@@ -67,13 +63,7 @@ impl Config {
6763 if !path. exists ( ) {
6864 return Err ( USimpleError :: new (
6965 BASE_CMD_PARSE_ERROR ,
70- get_message_with_args (
71- "base-common-no-such-file" ,
72- HashMap :: from ( [ (
73- "file" . to_string ( ) ,
74- path. maybe_quote ( ) . to_string ( ) ,
75- ) ] ) ,
76- ) ,
66+ translate ! ( "base-common-no-such-file" , "file" => path. maybe_quote( ) ) ,
7767 ) ) ;
7868 }
7969
@@ -89,10 +79,7 @@ impl Config {
8979 num. parse :: < usize > ( ) . map_err ( |_| {
9080 USimpleError :: new (
9181 BASE_CMD_PARSE_ERROR ,
92- get_message_with_args (
93- "base-common-invalid-wrap-size" ,
94- HashMap :: from ( [ ( "size" . to_string ( ) , num. quote ( ) . to_string ( ) ) ] ) ,
95- ) ,
82+ translate ! ( "base-common-invalid-wrap-size" , "size" => num. quote( ) ) ,
9683 )
9784 } )
9885 } )
@@ -128,15 +115,15 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
128115 . short ( 'd' )
129116 . visible_short_alias ( 'D' )
130117 . long ( options:: DECODE )
131- . help ( get_message ( "base-common-help-decode" ) )
118+ . help ( translate ! ( "base-common-help-decode" ) )
132119 . action ( ArgAction :: SetTrue )
133120 . overrides_with ( options:: DECODE ) ,
134121 )
135122 . arg (
136123 Arg :: new ( options:: IGNORE_GARBAGE )
137124 . short ( 'i' )
138125 . long ( options:: IGNORE_GARBAGE )
139- . help ( get_message ( "base-common-help-ignore-garbage" ) )
126+ . help ( translate ! ( "base-common-help-ignore-garbage" ) )
140127 . action ( ArgAction :: SetTrue )
141128 . overrides_with ( options:: IGNORE_GARBAGE ) ,
142129 )
@@ -145,10 +132,7 @@ pub fn base_app(about: &'static str, usage: &str) -> Command {
145132 . short ( 'w' )
146133 . long ( options:: WRAP )
147134 . value_name ( "COLS" )
148- . help ( get_message_with_args (
149- "base-common-help-wrap" ,
150- HashMap :: from ( [ ( "default" . to_string ( ) , WRAP_DEFAULT . to_string ( ) ) ] ) ,
151- ) )
135+ . help ( translate ! ( "base-common-help-wrap" , "default" => WRAP_DEFAULT ) )
152136 . overrides_with ( options:: WRAP ) ,
153137 )
154138 // "multiple" arguments are used to check whether there is more than one
@@ -830,10 +814,7 @@ fn format_read_error(kind: ErrorKind) -> String {
830814 }
831815 }
832816
833- get_message_with_args (
834- "base-common-read-error" ,
835- HashMap :: from ( [ ( "error" . to_string ( ) , kind_string_capitalized) ] ) ,
836- )
817+ translate ! ( "base-common-read-error" , "error" => kind_string_capitalized)
837818}
838819
839820#[ cfg( test) ]
0 commit comments