14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
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 "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"
#ifdef OF_AMIGAOS
|
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
|
-
-
+
-
+
-
|
}
+ (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];
@try {
#ifndef OF_AMIGAOS
|
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
518
|
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];
}
#ifdef OF_HAVE_FILES
- (void)addLocalizationDirectory: (OFString *)path
- (void)addLocalizationDirectoryURI: (OFURI *)URI
{
void *pool;
OFURI *mapURI, *localizationURI;
OFString *mapPath, *languageCode, *countryCode, *localizationFile;
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;
}
languageCode = _languageCode.lowercaseString;
|
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
|
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;
}
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;
va_list args;
|