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
#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







|
|
|







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
365
366
367
368
369
370
371
372
373
374
}

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

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

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

	@try {







|

|







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
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;







|


|








|

|







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
534
535
536
537
538
539
540
541
542
543
544
545
		    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, ...
{







|


|
|







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, ...
{