@@ -25,10 +25,11 @@ #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" #import "OFSHA384Hash.h" #import "OFSHA512Hash.h" #import "OFStdIOStream.h" +#import "OFLocalization.h" #import "OFOpenItemFailedException.h" #import "OFReadFailedException.h" @interface OFHash: OFObject @@ -37,14 +38,14 @@ OF_APPLICATION_DELEGATE(OFHash) static void help(void) { - [of_stderr writeFormat: - @"Usage: %@ [md5|rmd160|sha1|sha224|sha256|sha384|sha512] " - @"file1 [file2 ...]\n", - [OFApplication programName]]; + [of_stderr writeLine: OF_LOCALIZED(@"usage", + @"Usage: %[prog] [md5|rmd160|sha1|sha224|sha256|sha384|sha512] " + @"file1 [file2 ...]", + @"prog", [OFApplication programName])]; [OFApplication terminateWithStatus: 1]; } static id @@ -74,10 +75,12 @@ OFArray OF_GENERIC(OFString*) *arguments = [OFApplication arguments]; id hash; bool first = true; int exitStatus = 0; + [OFLocalization addLanguageDirectory: @LANGUAGE_DIR]; + if ([arguments count] < 2) help(); if ((hash = hashForName([arguments firstObject])) == nil) help(); @@ -100,13 +103,20 @@ else { @try { file = [OFFile fileWithPath: path mode: @"rb"]; } @catch (OFOpenItemFailedException *e) { - [of_stderr writeFormat: - @"Failed to open file %@: %s\n", - [e path], strerror([e errNo])]; + OFString *error = [OFString + stringWithCString: strerror([e errNo]) + encoding: [OFLocalization + encoding]]; + + [of_stderr writeLine: OF_LOCALIZED( + @"failed_to_open_file", + @"Failed to open file %[file]: %[error]", + @"file", [e path], + @"error", error)]; exitStatus = 1; goto outer_loop_end; } } @@ -119,13 +129,20 @@ @try { length = [file readIntoBuffer: buffer length: 1024]; } @catch (OFReadFailedException *e) { - [of_stderr writeFormat: - @"Failed to read %@: %s\n", - path, strerror([e errNo])]; + OFString *error = [OFString + stringWithCString: strerror([e errNo]) + encoding: [OFLocalization + encoding]]; + + [of_stderr writeLine: OF_LOCALIZED( + @"failed_to_read_file", + @"Failed to read %[file]: %[error]", + @"file", path, + @"error", error)]; exitStatus = 1; goto outer_loop_end; }