ObjFW
OFLocalization.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017
3  * Jonathan Schleifer <js@heap.zone>
4  *
5  * All rights reserved.
6  *
7  * This file is part of ObjFW. It may be distributed under the terms of the
8  * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
9  * the packaging of this file.
10  *
11  * Alternatively, it may be distributed under the terms of the GNU General
12  * Public License, either version 2 or 3, which can be found in the file
13  * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
14  * file.
15  */
16 
17 #import "OFObject.h"
18 #import "OFString.h"
19 
20 OF_ASSUME_NONNULL_BEGIN
21 
24 #define OF_LOCALIZED(ID, ...) \
25  [[OFLocalization sharedLocalization] \
26  localizedStringForID: ID \
27  fallback: __VA_ARGS__, nil]
28 
29 @class OFMutableArray OF_GENERIC(ObjectType);
30 @class OFDictionary OF_GENERIC(KeyType, ObjectType);
31 
38 {
39  OFString *_language;
40  OFString *_territory;
41  of_string_encoding_t _encoding;
42  OFString *_decimalPoint;
43  OFMutableArray OF_GENERIC(OFDictionary OF_GENERIC(OFString *, id) *)
44  *_localizedStrings;
45 }
46 
52 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *language;
53 
59 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *territory;
60 
69 @property (readonly, nonatomic) of_string_encoding_t encoding;
70 
74 @property (readonly, nonatomic) OFString *decimalPoint;
75 
85 + (instancetype)sharedLocalization;
86 
94 + (nullable OFString *)language;
95 
103 + (nullable OFString *)territory;
104 
116 
123 
124 #ifdef OF_HAVE_FILES
125 
130 + (void)addLanguageDirectory: (OFString *)path;
131 #endif
132 
143 - init;
144 
145 #ifdef OF_HAVE_FILES
146 
151 - (void)addLanguageDirectory: (OFString *)path;
152 #endif
153 
172 - (OFString *)localizedStringForID: (OFConstantString *)ID
173  fallback: (OFConstantString *)fallback, ...
174  OF_SENTINEL;
175 
197 - (OFString *)localizedStringForID: (OFConstantString *)ID
198  fallback: (OFConstantString *)fallback
199  arguments: (va_list)arguments;
200 @end
201 
202 OF_ASSUME_NONNULL_END
instancetype sharedLocalization()
Returns the shared OFLocalization instance.
Definition: OFLocalization.m:89
OFString * decimalPoint()
Returns the decimal point of the system&#39;s locale.
A class for handling strings.
Definition: OFString.h:114
A class for querying the locale and retrieving localized strings.
Definition: OFLocalization.h:37
nullable OFString * territory()
Returns the territory of the locale.
id init()
Initializes the OFLocalization singleton with the specified locale.
Definition: OFLocalization.m:121
An abstract class for storing objects in a dictionary.
Definition: OFDictionary.h:54
readonly
Definition: OFLocalization.h:52
The root class for all other classes inside ObjFW.
Definition: OFObject.h:379
A class for storing constant strings using the @"" literal.
Definition: OFConstantString.h:37
of_string_encoding_t
The encoding of a string.
Definition: OFString.h:53
nullable OFString * language()
Returns the language of the locale.
of_string_encoding_t encoding()
Returns the native 8-bit string encoding for the locale.
An abstract class for storing, adding and removing objects in an array.
Definition: OFMutableArray.h:40