2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FLclLocaleManager.h
19 * @brief This is the header file for the %LocaleManager class.
21 * This header file contains the declarations of the %LocaleManager class.
24 #ifndef _FLCL_LOCALE_MANAGER_H_
25 #define _FLCL_LOCALE_MANAGER_H_
27 #include <FBaseString.h>
28 #include <FBaseColIList.h>
29 #include <FLclTimeZone.h>
30 #include <FLclLocale.h>
32 namespace Tizen { namespace Locales
36 * @class LocaleManager
37 * @brief This class provides methods for %LocaleManager identification.
41 * @final This class is not intended for extension.
43 * The %LocaleManager class provides methods for the system locale information of the device. Each device system has at least
44 * one installed locale and often has many locales from which the user can choose.
46 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/locales/lang_country_codes.htm">Retrieving Language and Country Codes</a>.
49 * @see NumberFormatter
50 * @see DateTimeFormatter
52 * The following example demonstrates how to use the %LocaleManager class to get and set system locale information.
59 using namespace Tizen::Base;
60 using namespace Tizen::Locales;
63 LocaleApp::LocaleExample1(void)
65 LocaleManager localeManager;
66 localeManager.Construct();
68 // Gets the system locale information.
69 Locale systemLocale = localeManager.GetSystemLocale();
71 String countryCodeString = systemLocale.GetCountryCodeString();
72 String languageCodeString = systemLocale.GetLanguageCodeString();
73 String variantCodString = systemLocale.GetVariantCodeString();
75 // Gets the formatted number that is localized.
76 NumberFormatter* pNumberFormatter = NumberFormatter::CreateNumberFormatterN(systemLocale);
78 String formattedString;
79 long inputNumber = 123456;
80 pNumberFormatter->Format((long) inputNumber, formattedString);
82 // Gets the formatted date/time that is localized.
83 DateTimeFormatter* pDateTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(systemLocale);
85 dateTime.SetValue(2009, 2, 24, 15, 22, 00);
86 pDateTimeFormatter->Format(dateTime, formattedString);
88 // Gets the currency symbol that is localized.
89 NumberFormatter* pCurrencyFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
91 pCurrencyFormatter->Format(inputNumber, formattedString);
94 delete pNumberFormatter;
95 delete pDateTimeFormatter;
96 delete pCurrencyFormatter;
101 * The following example demonstrates how to use the %LocaleManager class to get a list of all the available locales from the system.
106 #include <FLocales.h>
108 using namespace Tizen::Base;
109 using namespace Tizen::Base::Collection;
110 using namespace Tizen::Locales;
113 LocaleApp::LocaleExample2(void)
115 LocaleManager localeManager;
116 localeManager.Construct();
118 IList* pAvailableLocales = localeManager.GetAvailableLocalesN();
119 if (pAvailableLocales)
121 for (int i = 0; i < pAvailableLocales->GetCount(); i++)
123 Locale* pLocale = (Locale*) (pAvailableLocales->GetAt(i));
125 String languageCodeString = pLocale->GetLanguageCodeString();
126 String countryCodeString = pLocale->GetCountryCodeString();
127 String variantCodString = pLocale->GetVariantCodeString();
138 class _OSP_EXPORT_ LocaleManager
139 : public Tizen::Base::Object
143 * This is the default constructor for this class. @n
144 * The object is not fully constructed after this constructor is called. For full construction, the Construct()
145 * method must be called right after calling this constructor.
153 * This is the destructor for this class. @n
154 * This destructor overrides Tizen::Base::Object::~Object().
158 virtual ~LocaleManager(void);
161 * Initializes this instance of %LocaleManager.
165 * @return An error code
166 * @exception E_SUCCESS The method is successful.
167 * @exception E_OUT_OF_MEMORY The memory is insufficient.
169 result Construct(void);
173 * Gets the system locale of the device.
177 * @return The system locale
178 * @exception E_SUCCESS The method is successful.
179 * @exception E_SYSTEM A system error has occurred.
181 * - The specific error code can be accessed using the GetLastResult() method.
182 * - The resulting Locale instance is Locale(@c LANGUAGE_INVALID, @c COUNTRY_INVALID).
184 Locale GetSystemLocale(void) const;
188 * Gets the list of all the available locales.
192 * @return The list of available locales, @n
193 * else @c null if it fails
194 * @exception E_SUCCESS The method is successful.
195 * @exception E_OUT_OF_MEMORY The memory is insufficient.
196 * @exception E_SYSTEM A system error has occurred.
198 * - The Tizen::Base::Collection::IList returned contains the list of all the locales installed on the system.
199 * - The specific error code can be accessed using the GetLastResult() method.
201 Tizen::Base::Collection::IList* GetAvailableLocalesN(void) const;
205 * Gets the currently selected language of the device by a user from the user setting menu.
209 * @return The user selected language as an instance of Tizen::Base::String (ISO 639-2 code format), @n
210 * else empty string if the method fails
211 * @exception E_SUCCESS The method is successful.
212 * @remarks The specific error code can be accessed using the GetLastResult() method.
214 Tizen::Base::String GetSelectedLanguage(void) const;
218 * Gets the list of all the available languages supported by the device, which can be different according to the target
219 * country/region of the device.
223 * @return The list of all available languages as Tizen::Base::String instances (ISO 639-2 code format), @n
224 * else @c null if it fails
225 * @exception E_SUCCESS The method is successful.
226 * @exception E_OUT_OF_MEMORY The memory is insufficient.
227 * @exception E_SYSTEM A system error has occurred.
228 * @remarks The specific error code can be accessed using the GetLastResult() method.
230 Tizen::Base::Collection::IList* GetAvailableLanguagesN(void) const;
234 * Gets the list of all the available time zone IDs.
238 * @return The list of all available time zone IDs as Tizen::Base::String instances, @n
239 * else @c null if it fails
240 * @exception E_SUCCESS The method is successful.
241 * @exception E_OUT_OF_MEMORY The memory is insufficient.
242 * @exception E_SYSTEM A system error has occurred.
243 * @remarks The specific error code can be accessed using the GetLastResult() method.
245 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(void) const;
249 * Gets the list of all the available time zone IDs with the specified Greenwich Mean Time (GMT) offset for this time zone.
253 * @return The list of all availabke time zone IDs with the GMT offset as Tizen::Base::String instances, @n
254 * else @c null if it fails
255 * @param[in] rawOffset The specified GMT offset for this time zone (Daylight Saving Time (DST) is not considered) @n
256 * The value of @c rawOffset is in minutes.
257 * @exception E_SUCCESS The method is successful.
258 * @exception E_OUT_OF_MEMORY The memory is insufficient.
259 * @exception E_SYSTEM A system error has occurred.
261 * - The specific error code can be accessed using the GetLastResult() method.
262 * - If there are no time zones for the specified GMT offset, an empty list is returned.
264 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(int rawOffset) const;
268 * Gets the default system time zone.
272 * @return The default system time zone, @n
273 * else the time zone name is an empty string and the offset is @c -1 if the method fails
274 * @exception E_SUCCESS The method is successful.
275 * @remarks The specific error code can be accessed using the GetLastResult() method.
277 TimeZone GetSystemTimeZone(void) const;
281 * Checks whether the specified instance of Locale is supported.
285 * @return An error code
286 * @param[in] locale An instance of Locale
287 * @param[out] isSupportedLocale The flag for checking the supported locale
288 * @exception E_SUCCESS The method is successful.
290 result IsSupportedLocale(const Locale& locale, bool& isSupportedLocale);
294 * The implementation of this copy constructor is intentionally blank and declared as private to
295 * prohibit copying of objects.
297 LocaleManager(const LocaleManager& localeManager);
300 * The implementation of this copy assignment operator is intentionally blank and declared as private
301 * to prohibit copying of objects.
303 LocaleManager& operator =(const LocaleManager& localeManager);
305 friend class _LocaleManagerImpl;
306 class _LocaleManagerImpl* __pLocaleManagerImpl;
311 #endif //_FLCL_LOCALE_MANAGER_H_