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 *_Nullable _language, *_Nullable _territory;
40  of_string_encoding_t _encoding;
41  OFString *_decimalPoint;
42  OFMutableArray OF_GENERIC(OFDictionary OF_GENERIC(OFString *, id) *)
43  *_localizedStrings;
44 }
45 
51 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *language;
52 
58 @property OF_NULLABLE_PROPERTY (readonly, nonatomic) OFString *territory;
59 
68 @property (readonly, nonatomic) of_string_encoding_t encoding;
69 
73 @property (readonly, nonatomic) OFString *decimalPoint;
74 
84 + (instancetype)sharedLocalization;
85 
93 + (nullable OFString *)language;
94 
102 + (nullable OFString *)territory;
103 
115 
122 
123 #ifdef OF_HAVE_FILES
124 
129 + (void)addLanguageDirectory: (OFString *)path;
130 #endif
131 
142 - init;
143 
144 #ifdef OF_HAVE_FILES
145 
150 - (void)addLanguageDirectory: (OFString *)path;
151 #endif
152 
171 - (OFString *)localizedStringForID: (OFConstantString *)ID
172  fallback: (OFConstantString *)fallback, ...
173  OF_SENTINEL;
174 
196 - (OFString *)localizedStringForID: (OFConstantString *)ID
197  fallback: (OFConstantString *)fallback
198  arguments: (va_list)arguments;
199 @end
200 
201 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:51
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