Differences From Artifact [552516ebb5]:
- File
src/OFLocale.m
— part of check-in
[88ed5be671]
at
2022-11-23 21:39:13
on branch trunk
— Use a URI for the localization directory
This theoretically allows embedding localizations. While this isn't
great as all will be held in memory but only one will be used, there
might be cases where everything should be in one binary. (user: js, size: 15623) [annotate] [blame] [check-ins using]
To Artifact [962451e814]:
- File src/OFLocale.m — part of check-in [23272e6d43] at 2022-11-24 00:21:15 on branch trunk — Rename OFURI to OFIRI (user: js, size: 15623) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
16 17 18 19 20 21 22 | #include "config.h" #include <locale.h> #import "OFLocale.h" #import "OFArray.h" #import "OFDictionary.h" | | | | | 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 "OFIRI.h" #import "OFNumber.h" #import "OFString.h" #import "OFInitializationFailedException.h" #import "OFInvalidArgumentException.h" #import "OFInvalidFormatException.h" #import "OFOpenItemFailedException.h" #ifdef OF_AMIGAOS |
︙ | ︙ | |||
358 359 360 361 362 363 364 | } + (OFString *)decimalSeparator { return currentLocale.decimalSeparator; } | | | | 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 | } + (OFString *)decimalSeparator { return currentLocale.decimalSeparator; } + (void)addLocalizationDirectoryIRI: (OFIRI *)IRI { [currentLocale addLocalizationDirectoryIRI: IRI]; } - (instancetype)init { self = [super init]; @try { |
︙ | ︙ | |||
489 490 491 492 493 494 495 | [_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)addLocalizationDirectoryIRI: (OFIRI *)IRI { void *pool; OFIRI *mapIRI, *localizationIRI; OFString *languageCode, *countryCode, *localizationFile; OFDictionary *map; if (_languageCode == nil) return; pool = objc_autoreleasePoolPush(); mapIRI = [IRI IRIByAppendingPathComponent: @"localizations.json"]; @try { map = [[OFString stringWithContentsOfIRI: mapIRI] objectByParsingJSON]; } @catch (OFOpenItemFailedException *e) { objc_autoreleasePoolPop(pool); return; } languageCode = _languageCode.lowercaseString; |
︙ | ︙ | |||
527 528 529 530 531 532 533 | 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 | objectForKey: @""]; if (localizationFile == nil) { objc_autoreleasePoolPop(pool); return; } localizationIRI = [IRI IRIByAppendingPathComponent: [localizationFile stringByAppendingString: @".json"]]; [_localizedStrings addObject: [[OFString stringWithContentsOfIRI: localizationIRI] objectByParsingJSON]]; objc_autoreleasePoolPop(pool); } - (OFString *)localizedStringForID: (OFConstantString *)ID fallback: (id)fallback, ... { |
︙ | ︙ |