ObjFW  Diff

Differences From Artifact [552516ebb5]:

To Artifact [962451e814]:


16
17
18
19
20
21
22
23
24
25



26
27
28
29
30
31
32
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 "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
365

366
367

368
369
370
371
372
373
374
358
359
360
361
362
363
364

365
366

367
368
369
370
371
372
373
374







-
+

-
+







}

+ (OFString *)decimalSeparator
{
	return currentLocale.decimalSeparator;
}

+ (void)addLocalizationDirectoryURI: (OFURI *)URI
+ (void)addLocalizationDirectoryIRI: (OFIRI *)IRI
{
	[currentLocale addLocalizationDirectoryURI: URI];
	[currentLocale addLocalizationDirectoryIRI: IRI];
}

- (instancetype)init
{
	self = [super init];

	@try {
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
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)addLocalizationDirectoryIRI: (OFIRI *)IRI
{
	void *pool;
	OFURI *mapURI, *localizationURI;
	OFIRI *mapIRI, *localizationIRI;
	OFString *languageCode, *countryCode, *localizationFile;
	OFDictionary *map;

	if (_languageCode == nil)
		return;

	pool = objc_autoreleasePoolPush();

	mapURI = [URI URIByAppendingPathComponent: @"localizations.json"];
	mapIRI = [IRI IRIByAppendingPathComponent: @"localizations.json"];
	@try {
		map = [[OFString stringWithContentsOfURI: mapURI]
		map = [[OFString stringWithContentsOfIRI: mapIRI]
		     objectByParsingJSON];
	} @catch (OFOpenItemFailedException *e) {
		objc_autoreleasePoolPop(pool);
		return;
	}

	languageCode = _languageCode.lowercaseString;
527
528
529
530
531
532
533
534

535
536
537
538


539
540
541
542
543
544
545
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;
	}

	localizationURI = [URI URIByAppendingPathComponent:
	localizationIRI = [IRI IRIByAppendingPathComponent:
	    [localizationFile stringByAppendingString: @".json"]];

	[_localizedStrings addObject: [[OFString stringWithContentsOfURI:
	    localizationURI] objectByParsingJSON]];
	[_localizedStrings addObject: [[OFString stringWithContentsOfIRI:
	    localizationIRI] objectByParsingJSON]];

	objc_autoreleasePoolPop(pool);
}

- (OFString *)localizedStringForID: (OFConstantString *)ID
			  fallback: (id)fallback, ...
{