Index: utils/ofhash/Makefile ================================================================== --- utils/ofhash/Makefile +++ utils/ofhash/Makefile @@ -1,13 +1,21 @@ include ../../extra.mk PROG = ofhash${PROG_SUFFIX} SRCS = OFHash.m +DATA = lang/de.json \ + lang/languages.json include ../../buildsys.mk + +PACKAGE_NAME = ofhash ${PROG}: ${LIBOBJFW_DEP_LVL2} -CPPFLAGS += -I../../src -I../../src/runtime -I../../src/exceptions -I../.. +CPPFLAGS += -I../../src \ + -I../../src/runtime \ + -I../../src/exceptions \ + -I../.. \ + -DLANGUAGE_DIR=\"${datadir}/ofhash/lang\" LIBS := -L../../src -lobjfw ${LIBS} LD = ${OBJC} LDFLAGS += ${LDFLAGS_RPATH} Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -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; } ADDED utils/ofhash/lang/de.json Index: utils/ofhash/lang/de.json ================================================================== --- utils/ofhash/lang/de.json +++ utils/ofhash/lang/de.json @@ -0,0 +1,8 @@ +{ + "usage": [ + "Benutzung: %[prog] [md5|rmd160|sha1|sha224|sha256|sha384|sha512] ", + "datei1 [datei2 ...]" + ], + "failed_to_open_file": "Fehler beim Öffnen der Datei %[file]: %[error]", + "failed_to_read_file": "Fehler beim Lesen der Datei %[file]: %[error]" +} ADDED utils/ofhash/lang/languages.json Index: utils/ofhash/lang/languages.json ================================================================== --- utils/ofhash/lang/languages.json +++ utils/ofhash/lang/languages.json @@ -0,0 +1,8 @@ +{ + "de": { + "": "de" + }, + "german": { + "": "de" + } +}