@@ -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
@@ -576,17 +584,18 @@ fn get_input_file(filename: &OsStr) -> UResult<Box<dyn Read>> {
576584 match File :: open ( filename) {
577585 Ok ( f) => {
578586 if f. metadata ( ) ?. is_dir ( ) {
579- Err (
580- io:: Error :: other ( format ! ( "{}: Is a directory" , filename. to_string_lossy( ) ) )
581- . into ( ) ,
587+ Err ( io:: Error :: other (
588+ translate ! ( "error-is-a-directory" , "file" => filename. to_string_lossy( ) ) ,
582589 )
590+ . into ( ) )
583591 } else {
584592 Ok ( Box :: new ( f) )
585593 }
586594 }
587595 Err ( _) => Err ( io:: Error :: other ( format ! (
588- "{}: No such file or directory" ,
589- filename. to_string_lossy( )
596+ "{}: {}" ,
597+ filename. to_string_lossy( ) ,
598+ translate!( "error-file-not-found" )
590599 ) )
591600 . into ( ) ) ,
592601 }
@@ -864,11 +873,9 @@ fn process_checksum_file(
864873 } else {
865874 "Unknown algorithm"
866875 } ;
867- eprintln ! (
868- "{}: {}: {}: improperly formatted {algo} checksum line" ,
869- util_name( ) ,
870- filename_input. maybe_quote( ) ,
871- i + 1 ,
876+ show_error ! (
877+ "{}" ,
878+ translate!( "checksum-error-algo-bad-format" , "file" => filename_input. maybe_quote( ) , "line" => i + 1 , "algo" => algo)
872879 ) ;
873880 }
874881 }
0 commit comments