@@ -18,7 +18,7 @@ use crate::quoting_style::{QuotingStyle, locale_aware_escape_name};
1818use crate :: sum:: DigestOutput ;
1919use crate :: {
2020 os_str_as_bytes, os_str_from_bytes, read_os_string_lines, show, show_error, show_warning_caps,
21- util_name ,
21+ translate ,
2222} ;
2323
2424/// To what level should checksum validation print logging info.
@@ -147,37 +147,45 @@ impl From<ChecksumError> for FileCheckError {
147147 }
148148}
149149
150- #[ allow( clippy:: comparison_chain) ]
151150fn print_cksum_report ( res : & ChecksumResult ) {
152- if res. bad_format == 1 {
153- show_warning_caps ! ( "{} line is improperly formatted" , res. bad_format) ;
154- } else if res. bad_format > 1 {
155- show_warning_caps ! ( "{} lines are improperly formatted" , res. bad_format) ;
151+ if res. bad_format > 0 {
152+ show_warning_caps ! (
153+ "{}" ,
154+ translate!( "checksum-bad-format" , "count" => res. bad_format)
155+ ) ;
156156 }
157157
158- if res. failed_cksum == 1 {
159- show_warning_caps ! ( "{} computed checksum did NOT match" , res. failed_cksum) ;
160- } else if res. failed_cksum > 1 {
161- show_warning_caps ! ( "{} computed checksums did NOT match" , res. failed_cksum) ;
158+ if res. failed_cksum > 0 {
159+ show_warning_caps ! (
160+ "{}" ,
161+ translate!( "checksum-failed-cksum" , "count" => res. failed_cksum)
162+ ) ;
162163 }
163164
164- if res. failed_open_file == 1 {
165- show_warning_caps ! ( "{} listed file could not be read" , res. failed_open_file) ;
166- } else if res. failed_open_file > 1 {
167- show_warning_caps ! ( "{} listed files could not be read" , res. failed_open_file) ;
165+ if res. failed_open_file > 0 {
166+ show_warning_caps ! (
167+ "{}" ,
168+ translate!( "checksum-failed-open-file" , "count" => res. failed_open_file)
169+ ) ;
168170 }
169171}
170172
171173/// Print a "no properly formatted lines" message in stderr
172174#[ inline]
173175fn log_no_properly_formatted ( filename : impl Display ) {
174- show_error ! ( "{filename}: no properly formatted checksum lines found" ) ;
176+ show_error ! (
177+ "{}" ,
178+ translate!( "checksum-no-properly-formatted" , "checksum_file" => filename)
179+ ) ;
175180}
176181
177182/// Print a "no file was verified" message in stderr
178183#[ inline]
179184fn log_no_file_verified ( filename : impl Display ) {
180- show_error ! ( "{filename}: no file was verified" ) ;
185+ show_error ! (
186+ "{}" ,
187+ translate!( "checksum-no-file-verified" , "checksum_file" => filename)
188+ ) ;
181189}
182190
183191/// Represents the different outcomes that can happen to a file
@@ -582,17 +590,18 @@ fn get_input_file(filename: &OsStr) -> UResult<Box<dyn Read>> {
582590 match File :: open ( filename) {
583591 Ok ( f) => {
584592 if f. metadata ( ) ?. is_dir ( ) {
585- Err (
586- io:: Error :: other ( format ! ( "{}: Is a directory" , filename. to_string_lossy( ) ) )
587- . into ( ) ,
593+ Err ( io:: Error :: other (
594+ translate ! ( "error-is-a-directory" , "file" => filename. to_string_lossy( ) ) ,
588595 )
596+ . into ( ) )
589597 } else {
590598 Ok ( Box :: new ( f) )
591599 }
592600 }
593601 Err ( _) => Err ( io:: Error :: other ( format ! (
594- "{}: No such file or directory" ,
595- filename. to_string_lossy( )
602+ "{}: {}" ,
603+ filename. to_string_lossy( ) ,
604+ translate!( "error-file-not-found" )
596605 ) )
597606 . into ( ) ) ,
598607 }
@@ -875,11 +884,9 @@ fn process_checksum_file(
875884 } else {
876885 "Unknown algorithm"
877886 } ;
878- eprintln ! (
879- "{}: {}: {}: improperly formatted {algo} checksum line" ,
880- util_name( ) ,
881- filename_input. maybe_quote( ) ,
882- i + 1 ,
887+ show_error ! (
888+ "{}" ,
889+ translate!( "checksum-error-algo-bad-format" , "file" => filename_input. maybe_quote( ) , "line" => i + 1 , "algo" => algo)
883890 ) ;
884891 }
885892 }
0 commit comments