@@ -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.
@@ -149,35 +149,44 @@ impl From<ChecksumError> for FileCheckError {
149149
150150#[ allow( clippy:: comparison_chain) ]
151151fn 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) ;
152+ if res. bad_format > 0 {
153+ show_warning_caps ! (
154+ "{}" ,
155+ translate!( "checksum-bad-format" , "count" => res. bad_format)
156+ ) ;
156157 }
157158
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) ;
159+ if res. failed_cksum > 0 {
160+ show_warning_caps ! (
161+ "{}" ,
162+ translate!( "checksum-failed-cksum" , "count" => res. failed_cksum)
163+ ) ;
162164 }
163165
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) ;
166+ if res. failed_open_file > 0 {
167+ show_warning_caps ! (
168+ "{}" ,
169+ translate!( "checksum-failed-open-file" , "count" => res. failed_open_file)
170+ ) ;
168171 }
169172}
170173
171174/// Print a "no properly formatted lines" message in stderr
172175#[ inline]
173176fn log_no_properly_formatted ( filename : impl Display ) {
174- show_error ! ( "{filename}: no properly formatted checksum lines found" ) ;
177+ show_error ! (
178+ "{}" ,
179+ translate!( "checksum-no-properly-formatted" , "checksum_file" => filename)
180+ ) ;
175181}
176182
177183/// Print a "no file was verified" message in stderr
178184#[ inline]
179185fn log_no_file_verified ( filename : impl Display ) {
180- show_error ! ( "{filename}: no file was verified" ) ;
186+ show_error ! (
187+ "{}" ,
188+ translate!( "checksum-no-file-verified" , "checksum_file" => filename)
189+ ) ;
181190}
182191
183192/// Represents the different outcomes that can happen to a file
@@ -582,17 +591,18 @@ fn get_input_file(filename: &OsStr) -> UResult<Box<dyn Read>> {
582591 match File :: open ( filename) {
583592 Ok ( f) => {
584593 if f. metadata ( ) ?. is_dir ( ) {
585- Err (
586- io:: Error :: other ( format ! ( "{}: Is a directory" , filename. to_string_lossy( ) ) )
587- . into ( ) ,
594+ Err ( io:: Error :: other (
595+ translate ! ( "error-is-a-directory" , "file" => filename. display( ) ) ,
588596 )
597+ . into ( ) )
589598 } else {
590599 Ok ( Box :: new ( f) )
591600 }
592601 }
593602 Err ( _) => Err ( io:: Error :: other ( format ! (
594- "{}: No such file or directory" ,
595- filename. to_string_lossy( )
603+ "{}: {}" ,
604+ filename. to_string_lossy( ) ,
605+ translate!( "error-file-not-found" )
596606 ) )
597607 . into ( ) ) ,
598608 }
@@ -875,12 +885,10 @@ fn process_checksum_file(
875885 } else {
876886 "Unknown algorithm"
877887 } ;
878- eprintln ! (
879- "{}: {}: {}: improperly formatted {algo} checksum line" ,
880- util_name( ) ,
881- filename_input. maybe_quote( ) ,
882- i + 1 ,
883- ) ;
888+ show_error ! (
889+ "{}" ,
890+ translate!( "checksum-error-algo-bad-format" , "file" => filename_input. maybe_quote( ) , "line" => i + 1 , "algo" => algo)
891+ )
884892 }
885893 }
886894 Err ( CantOpenFile | FileIsDirectory ) => res. failed_open_file += 1 ,
0 commit comments