ObjFW
Loading...
Searching...
No Matches
OFLocale.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#import "OFObject.h"
17#import "OFString.h"
18
19OF_ASSUME_NONNULL_BEGIN
20
21@class OFIRI;
22
36#define OF_LOCALIZED(ID, ...) \
37 [[OFLocale currentLocale] localizedStringForID: ID \
38 fallback: __VA_ARGS__, nil]
39
40@class OFMutableArray OF_GENERIC(ObjectType);
41@class OFDictionary OF_GENERIC(KeyType, ObjectType);
42
48OF_SUBCLASSING_RESTRICTED
49@interface OFLocale: OFObject
50{
51 OFString *_Nullable _languageCode, *_Nullable _countryCode;
52 OFStringEncoding _encoding;
53 OFString *_decimalSeparator;
54 OFMutableArray OF_GENERIC(OFDictionary OF_GENERIC(OFString *, id) *)
55 *_localizedStrings;
56}
57
58#ifdef OF_HAVE_CLASS_PROPERTIES
59@property (class, readonly, nullable, nonatomic) OFLocale *currentLocale;
60@property (class, readonly, nullable, nonatomic) OFString *languageCode;
61@property (class, readonly, nullable, nonatomic) OFString *countryCode;
62@property (class, readonly, nonatomic) OFStringEncoding encoding;
63@property (class, readonly, nullable, nonatomic) OFString *decimalSeparator;
64#endif
65
71@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *languageCode;
72
78@property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *countryCode;
79
88@property (readonly, nonatomic) OFStringEncoding encoding;
89
93@property (readonly, nonatomic) OFString *decimalSeparator;
94
104+ (nullable OFLocale *)currentLocale;
105
113+ (nullable OFString *)languageCode;
114
122+ (nullable OFString *)countryCode;
123
134+ (OFStringEncoding)encoding;
135
141+ (nullable OFString *)decimalSeparator;
142
148+ (void)addLocalizationDirectoryIRI: (OFIRI *)IRI;
149
160- (instancetype)init;
161
167- (void)addLocalizationDirectoryIRI: (OFIRI *)IRI;
168
188- (OFString *)localizedStringForID: (OFConstantString *)ID
189 fallback: (id)fallback, ... OF_SENTINEL;
190
215- (OFString *)localizedStringForID: (OFConstantString *)ID
216 fallback: (id)fallback
217 arguments: (va_list)arguments;
218@end
219
220OF_ASSUME_NONNULL_END
OFStringEncoding
The encoding of a string.
Definition OFString.h:61
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:38
An abstract class for storing objects in a dictionary.
Definition OFDictionary.h:80
A class for representing IRIs, URIs, URLs and URNs, for parsing them as well as accessing parts of th...
Definition OFIRI.h:37
A class for querying the locale and retrieving localized strings.
Definition OFLocale.h:50
OFString * languageCode
The language code of the locale for messages.
Definition OFLocale.h:71
OFString * countryCode
The country code of the locale for messages.
Definition OFLocale.h:78
An abstract class for storing, adding and removing objects in an array.
Definition OFMutableArray.h:44
The root class for all other classes inside ObjFW.
Definition OFObject.h:688
A class for handling strings.
Definition OFString.h:135