Overview
Comment: | Use a URI for the localization directory
This theoretically allows embedding localizations. While this isn't |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
88ed5be67150e44cf848dab20453ddf6 |
User & Date: | js on 2022-11-23 21:39:13 |
Other Links: | manifest | tags |
Context
2022-11-23
| ||
21:45 | OFTarArchive: Fix iterating without reading check-in: 0966f1b371 user: js tags: trunk | |
21:39 | Use a URI for the localization directory check-in: 88ed5be671 user: js tags: trunk | |
2022-11-17
| ||
14:50 | Fix embedded files with GCC check-in: 722bb308e8 user: js tags: trunk | |
Changes
Modified src/OFLocale.h from [ca12b9c93f] to [11147ec893].
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 23 24 25 26 27 | */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN /** @file */ /** * @def OF_LOCALIZED * * @brief Returns the localized string for the specified ID with the specified * arguments inserted. | > > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | */ #import "OFObject.h" #import "OFString.h" OF_ASSUME_NONNULL_BEGIN @class OFURI; /** @file */ /** * @def OF_LOCALIZED * * @brief Returns the localized string for the specified ID with the specified * arguments inserted. |
︙ | ︙ | |||
134 135 136 137 138 139 140 | /** * @brief Returns the decimal point of the system's locale. * * @return The decimal point of the system's locale */ + (nullable OFString *)decimalSeparator; | < | | < < | | < | 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | /** * @brief Returns the decimal point of the system's locale. * * @return The decimal point of the system's locale */ + (nullable OFString *)decimalSeparator; /** * @brief Adds a directory to scan for localizations. * * @param URI The URI to the directory to scan for localizations */ + (void)addLocalizationDirectoryURI: (OFURI *)URI; /** * @brief Initializes the current OFLocale. * * @warning This sets the locale via `setlocale()`! * * @warning You should never call this yourself, except if you do not use * @ref OFApplication. In this case, you need to allocate exactly one * instance of OFLocale, which will become the current locale, and * call this method. */ - (instancetype)init; /** * @brief Adds a directory to scan for localizations. * * @param URI The URI to the directory to scan for localizations */ - (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. * * @note This takes a variadic argument, terminated by `nil`, that consists of * pairs of variable names and variable values, which will be replaced |
︙ | ︙ |
Modified src/OFLocale.m from [e8b5569b76] to [552516ebb5].
︙ | ︙ | |||
14 15 16 17 18 19 20 | */ #include "config.h" #include <locale.h> #import "OFLocale.h" | < > > | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | */ #include "config.h" #include <locale.h> #import "OFLocale.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" #ifdef OF_AMIGAOS |
︙ | ︙ | |||
357 358 359 360 361 362 363 | } + (OFString *)decimalSeparator { return currentLocale.decimalSeparator; } | < | | < | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | } + (OFString *)decimalSeparator { return currentLocale.decimalSeparator; } + (void)addLocalizationDirectoryURI: (OFURI *)URI { [currentLocale addLocalizationDirectoryURI: URI]; } - (instancetype)init { self = [super init]; @try { #ifndef OF_AMIGAOS |
︙ | ︙ | |||
490 491 492 493 494 495 496 | [_countryCode release]; [_decimalSeparator release]; [_localizedStrings release]; [super dealloc]; } | < | > | | | | 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | [_countryCode release]; [_decimalSeparator release]; [_localizedStrings release]; [super dealloc]; } - (void)addLocalizationDirectoryURI: (OFURI *)URI { void *pool; OFURI *mapURI, *localizationURI; OFString *languageCode, *countryCode, *localizationFile; OFDictionary *map; if (_languageCode == nil) return; pool = objc_autoreleasePoolPush(); mapURI = [URI URIByAppendingPathComponent: @"localizations.json"]; @try { map = [[OFString stringWithContentsOfURI: mapURI] objectByParsingJSON]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } languageCode = _languageCode.lowercaseString; |
︙ | ︙ | |||
528 529 530 531 532 533 534 | objectForKey: @""]; if (localizationFile == nil) { objc_autoreleasePoolPop(pool); return; } | | | | < | 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 | objectForKey: @""]; if (localizationFile == nil) { objc_autoreleasePoolPop(pool); return; } localizationURI = [URI URIByAppendingPathComponent: [localizationFile stringByAppendingString: @".json"]]; [_localizedStrings addObject: [[OFString stringWithContentsOfURI: localizationURI] objectByParsingJSON]]; objc_autoreleasePoolPop(pool); } - (OFString *)localizedStringForID: (OFConstantString *)ID fallback: (id)fallback, ... { OFString *ret; va_list args; |
︙ | ︙ |
Modified utils/ofarc/OFArc.m from [1abc9749ff] to [448648acfa].
︙ | ︙ | |||
203 204 205 206 207 208 209 | /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS | | > | | | 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; #else [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @"PROGDIR:/share/ofarc/localization"]]; #endif optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'f': if (_overwrite < 0) |
︙ | ︙ |
Modified utils/ofdns/OFDNS.m from [32af1e7083] to [9c8d151d03].
︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #import "OFApplication.h" #import "OFArray.h" #import "OFDNSResolver.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFSandbox.h" #import "OFStdIOStream.h" @interface OFDNS: OFObject <OFApplicationDelegate, OFDNSResolverQueryDelegate> { size_t _inFlight; int _errors; } @end | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | #import "OFApplication.h" #import "OFArray.h" #import "OFDNSResolver.h" #import "OFLocale.h" #import "OFOptionsParser.h" #import "OFSandbox.h" #import "OFStdIOStream.h" #import "OFURI.h" @interface OFDNS: OFObject <OFApplicationDelegate, OFDNSResolverQueryDelegate> { size_t _inFlight; int _errors; } @end |
︙ | ︙ | |||
95 96 97 98 99 100 101 | OFUnichar option; OFArray OF_GENERIC(OFString *) *remainingArguments; OFDNSResolver *resolver; OFDNSClass DNSClass; #ifdef OF_HAVE_FILES # ifndef OF_AMIGAOS | | > | | | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | OFUnichar option; OFArray OF_GENERIC(OFString *) *remainingArguments; OFDNSResolver *resolver; OFDNSClass DNSClass; #ifdef OF_HAVE_FILES # ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; # else [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @"PROGDIR:/share/ofdns/localization"]]; # endif #endif #ifdef OF_HAVE_SANDBOX OFSandbox *sandbox = [[OFSandbox alloc] init]; @try { sandbox.allowsStdIO = true; |
︙ | ︙ |
Modified utils/ofhash/OFHash.m from [8b4892a5e2] to [9ba8d5174c].
︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 | #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" #import "OFSHA384Hash.h" #import "OFSHA512Hash.h" #import "OFSandbox.h" #import "OFSecureData.h" #import "OFStdIOStream.h" #import "OFOpenItemFailedException.h" #import "OFReadFailedException.h" @interface OFHash: OFObject <OFApplicationDelegate> @end | > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #import "OFSHA224Hash.h" #import "OFSHA256Hash.h" #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 <OFApplicationDelegate> @end |
︙ | ︙ | |||
91 92 93 94 95 96 97 | OFSHA1Hash *SHA1Hash = nil; OFSHA224Hash *SHA224Hash = nil; OFSHA256Hash *SHA256Hash = nil; OFSHA384Hash *SHA384Hash = nil; OFSHA512Hash *SHA512Hash = nil; #ifndef OF_AMIGAOS | | > | | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 | OFSHA1Hash *SHA1Hash = nil; OFSHA224Hash *SHA224Hash = nil; OFSHA256Hash *SHA256Hash = nil; OFSHA384Hash *SHA384Hash = nil; OFSHA512Hash *SHA512Hash = nil; #ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; #else [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @"PROGDIR:/share/ofhash/localization"]]; #endif while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case '?': if (optionsParser.lastLongOption != nil) [OFStdErr writeLine: |
︙ | ︙ |
Modified utils/ofhttp/OFHTTP.m from [4bdf3b8ffc] to [05abbe7837].
︙ | ︙ | |||
447 448 449 450 451 452 453 | /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS | | > | | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 | /* Dropped after parsing options */ sandbox.allowsUnveil = true; [OFApplication of_activateSandbox: sandbox]; #endif #ifndef OF_AMIGAOS [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @LOCALIZATION_DIR]]; #else [OFLocale addLocalizationDirectoryURI: [OFURI fileURIWithPath: @"PROGDIR:/share/ofhttp/localization"]]; #endif optionsParser = [OFOptionsParser parserWithOptions: options]; while ((option = [optionsParser nextOption]) != '\0') { switch (option) { case 'b': [self setBody: optionsParser.argument]; |
︙ | ︙ |