Differences From Artifact [93e52fa91a]:
- File
src/OFLocalization.h
— part of check-in
[44f45c2e35]
at
2017-01-09 17:36:36
on branch trunk
— Update copyright
Forgot to add 2017, even though I already did quite some changes in
2017. (user: js, size: 5495) [annotate] [blame] [check-ins using]
To Artifact [e9be33b3dd]:
- File src/OFLocalization.h — part of check-in [e731dc4c75] at 2017-01-10 19:39:13 on branch trunk — Implement support for localized strings (user: js, size: 6053) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | /*! @file */ #define OF_LOCALIZED(ID, ...) \ [[OFLocalization sharedLocalization] \ localizedStringForID: ID \ fallback: __VA_ARGS__, nil] /*! * @class OFLocalization OFLocalization.h ObjFW/OFLocalization.h * * @brief A class for querying the locale and retrieving localized strings. */ @interface OFLocalization: OFObject { OFString *_language; OFString *_territory; of_string_encoding_t _encoding; OFString *_decimalPoint; } /** * The language of the locale. * * If the language is unknown, it is `nil`. */ | > > > > > | 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | /*! @file */ #define OF_LOCALIZED(ID, ...) \ [[OFLocalization sharedLocalization] \ localizedStringForID: ID \ fallback: __VA_ARGS__, nil] @class OFMutableArray OF_GENERIC(ObjectType); @class OFDictionary OF_GENERIC(KeyType, ObjectType); /*! * @class OFLocalization OFLocalization.h ObjFW/OFLocalization.h * * @brief A class for querying the locale and retrieving localized strings. */ @interface OFLocalization: OFObject { OFString *_language; OFString *_territory; of_string_encoding_t _encoding; OFString *_decimalPoint; OFMutableArray OF_GENERIC(OFDictionary OF_GENERIC(OFString*, id)*) *_localizedStrings; } /** * The language of the locale. * * If the language is unknown, it is `nil`. */ |
︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 | /*! * @brief Returns the decimal point of the system's locale. * * @return The decimal point of the system's locale */ + (OFString*)decimalPoint; /*! * @brief Initializes the OFLocalization singleton with the specified locale. * * @warning You should never call this yourself, except if you do not use * @ref OFApplication. In this case, you need to allocate exactly one * instance of OFLocalization, which will be come the singleton, and * call this method. * * @param locale The locale used, as returned from `setlocale()` */ - initWithLocale: (char*)locale; /*! * @brief Returns the localized string for the specified ID, using the fallback * string if it cannot be looked up or is missing. * * @note This takes a variadic argument, terminated by `nil`, that consists of * pairs of variable names and variable values, which will be replaced * inside the localized string. For example, you can pass * `@"name", @"foo", nil`, causing `%[name]` to be replaced with `foo` in * the localized string. * * @note Generally, you want to use @ref OF_LOCALIZED instead, which also takes * care of the `nil` sentinel automatically. * * @param ID The ID for the localized string * @param fallback The fallback to use in case the localized string cannot be * looked up or is missing * @return The localized string */ - (OFString*)localizedStringForID: (OFConstantString*)ID fallback: (OFConstantString*)fallback, ... OF_SENTINEL; /** * @brief Returns the localized string for the specified ID, using the fallback * string if it cannot be looked up or is missing. * * @note This takes a variadic argument, terminated by `nil` and passed as * va_list, that consists of pairs of variable names and variable values, * which will be replaced inside the localized string. For example, you | > > > > > > > > > > > > > > > | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | /*! * @brief Returns the decimal point of the system's locale. * * @return The decimal point of the system's locale */ + (OFString*)decimalPoint; /*! * @brief Adds a directory to scan for language files. * * @param path The path to the directory to scan for language files */ + (void)addLanguageDirectory: (OFString*)path; /*! * @brief Initializes the OFLocalization singleton with the specified locale. * * @warning You should never call this yourself, except if you do not use * @ref OFApplication. In this case, you need to allocate exactly one * instance of OFLocalization, which will be come the singleton, and * call this method. * * @param locale The locale used, as returned from `setlocale()` */ - initWithLocale: (char*)locale; /*! * @brief Adds a directory to scan for language files. * * @param path The path to the directory to scan for language files */ - (void)addLanguageDirectory: (OFString*)path; /*! * @brief Returns the localized string for the specified ID, using the fallback * string if it cannot be looked up or is missing. * * @note This takes a variadic argument, terminated by `nil`, that consists of * pairs of variable names and variable values, which will be replaced * inside the localized string. For example, you can pass * `@"name", @"foo", nil`, causing `%[name]` to be replaced with `foo` in * the localized string. * * @note Generally, you want to use @ref OF_LOCALIZED instead, which also takes * care of the `nil` sentinel automatically. * * @param ID The ID for the localized string * @param fallback The fallback to use in case the localized string cannot be * looked up or is missing * @return The localized string */ - (OFString*)localizedStringForID: (OFConstantString*)ID fallback: (OFConstantString*)fallback, ... OF_SENTINEL; /** * @brief Returns the localized string for the specified ID, using the fallback * string if it cannot be looked up or is missing. * * @note This takes a variadic argument, terminated by `nil` and passed as * va_list, that consists of pairs of variable names and variable values, * which will be replaced inside the localized string. For example, you |
︙ | ︙ |