Index: src/OFLocale.h ================================================================== --- src/OFLocale.h +++ src/OFLocale.h @@ -16,10 +16,12 @@ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN +@class OFURI; + /** @file */ /** * @def OF_LOCALIZED * @@ -136,18 +138,16 @@ * * @return The decimal point of the system's locale */ + (nullable OFString *)decimalSeparator; -#ifdef OF_HAVE_FILES /** * @brief Adds a directory to scan for localizations. * - * @param path The path to the directory to scan for localizations + * @param URI The URI to the directory to scan for localizations */ -+ (void)addLocalizationDirectory: (OFString *)path; -#endif ++ (void)addLocalizationDirectoryURI: (OFURI *)URI; /** * @brief Initializes the current OFLocale. * * @warning This sets the locale via `setlocale()`! @@ -157,18 +157,16 @@ * instance of OFLocale, which will become the current locale, and * call this method. */ - (instancetype)init; -#ifdef OF_HAVE_FILES /** * @brief Adds a directory to scan for localizations. * - * @param path The path to the directory to scan for localizations + * @param URI The URI to the directory to scan for localizations */ -- (void)addLocalizationDirectory: (OFString *)path; -#endif +- (void)addLocalizationDirectoryURI: (OFURI *)URI; /** * @brief Returns the localized string for the specified ID, using the fallback * string if it cannot be looked up or is missing. * Index: src/OFLocale.m ================================================================== --- src/OFLocale.m +++ src/OFLocale.m @@ -16,14 +16,15 @@ #include "config.h" #include #import "OFLocale.h" -#import "OFString.h" #import "OFArray.h" #import "OFDictionary.h" #import "OFNumber.h" +#import "OFString.h" +#import "OFURI.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" @@ -359,16 +360,14 @@ + (OFString *)decimalSeparator { return currentLocale.decimalSeparator; } -#ifdef OF_HAVE_FILES -+ (void)addLocalizationDirectory: (OFString *)path ++ (void)addLocalizationDirectoryURI: (OFURI *)URI { - [currentLocale addLocalizationDirectory: path]; + [currentLocale addLocalizationDirectoryURI: URI]; } -#endif - (instancetype)init { self = [super init]; @@ -492,25 +491,25 @@ [_localizedStrings release]; [super dealloc]; } -#ifdef OF_HAVE_FILES -- (void)addLocalizationDirectory: (OFString *)path +- (void)addLocalizationDirectoryURI: (OFURI *)URI { void *pool; - OFString *mapPath, *languageCode, *countryCode, *localizationFile; + OFURI *mapURI, *localizationURI; + OFString *languageCode, *countryCode, *localizationFile; OFDictionary *map; if (_languageCode == nil) return; pool = objc_autoreleasePoolPush(); - mapPath = [path stringByAppendingPathComponent: @"localizations.json"]; + mapURI = [URI URIByAppendingPathComponent: @"localizations.json"]; @try { - map = [[OFString stringWithContentsOfFile: mapPath] + map = [[OFString stringWithContentsOfURI: mapURI] objectByParsingJSON]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } @@ -530,19 +529,18 @@ if (localizationFile == nil) { objc_autoreleasePoolPop(pool); return; } - localizationFile = [path stringByAppendingPathComponent: + localizationURI = [URI URIByAppendingPathComponent: [localizationFile stringByAppendingString: @".json"]]; - [_localizedStrings addObject: [[OFString stringWithContentsOfFile: - localizationFile] objectByParsingJSON]]; + [_localizedStrings addObject: [[OFString stringWithContentsOfURI: + localizationURI] objectByParsingJSON]]; objc_autoreleasePoolPop(pool); } -#endif - (OFString *)localizedStringForID: (OFConstantString *)ID fallback: (id)fallback, ... { OFString *ret; Index: utils/ofarc/OFArc.m ================================================================== --- utils/ofarc/OFArc.m +++ utils/ofarc/OFArc.m @@ -205,14 +205,15 @@ [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS - [OFLocale addLocalizationDirectory: @LOCALIZATION_DIR]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; #else - [OFLocale addLocalizationDirectory: - @"PROGDIR:/share/ofarc/localization"]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @"PROGDIR:/share/ofarc/localization"]]; #endif optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { Index: utils/ofdns/OFDNS.m ================================================================== --- utils/ofdns/OFDNS.m +++ utils/ofdns/OFDNS.m @@ -20,10 +20,11 @@ #import "OFDNSResolver.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFSandbox.h" #import "OFStdIOStream.h" +#import "OFURI.h" @interface OFDNS: OFObject { size_t _inFlight; int _errors; @@ -97,14 +98,15 @@ OFDNSResolver *resolver; OFDNSClass DNSClass; #ifdef OF_HAVE_FILES # ifndef OF_AMIGAOS - [OFLocale addLocalizationDirectory: @LOCALIZATION_DIR]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; # else - [OFLocale addLocalizationDirectory: - @"PROGDIR:/share/ofdns/localization"]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @"PROGDIR:/share/ofdns/localization"]]; # endif #endif #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [[OFSandbox alloc] init]; Index: utils/ofhash/OFHash.m ================================================================== --- utils/ofhash/OFHash.m +++ utils/ofhash/OFHash.m @@ -28,10 +28,11 @@ #import "OFSHA384Hash.h" #import "OFSHA512Hash.h" #import "OFSandbox.h" #import "OFSecureData.h" #import "OFStdIOStream.h" +#import "OFURI.h" #import "OFOpenItemFailedException.h" #import "OFReadFailedException.h" @interface OFHash: OFObject @@ -93,14 +94,15 @@ OFSHA256Hash *SHA256Hash = nil; OFSHA384Hash *SHA384Hash = nil; OFSHA512Hash *SHA512Hash = nil; #ifndef OF_AMIGAOS - [OFLocale addLocalizationDirectory: @LOCALIZATION_DIR]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; #else - [OFLocale addLocalizationDirectory: - @"PROGDIR:/share/ofhash/localization"]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @"PROGDIR:/share/ofhash/localization"]]; #endif while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case '?': Index: utils/ofhttp/OFHTTP.m ================================================================== --- utils/ofhttp/OFHTTP.m +++ utils/ofhttp/OFHTTP.m @@ -449,14 +449,15 @@ [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS - [OFLocale addLocalizationDirectory: @LOCALIZATION_DIR]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; #else - [OFLocale addLocalizationDirectory: - @"PROGDIR:/share/ofhttp/localization"]; + [OFLocale addLocalizationDirectoryURI: + [OFURI fileURIWithPath: @"PROGDIR:/share/ofhttp/localization"]]; #endif optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) {