2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FLclLocaleManager.h
20 * @brief This is the header file for the %LocaleManager class.
22 * This header file contains the declarations of the %LocaleManager class.
25 #ifndef _FLCL_LOCALE_MANAGER_H_
26 #define _FLCL_LOCALE_MANAGER_H_
28 #include <FBaseString.h>
29 #include <FBaseColIList.h>
30 #include <FLclTimeZone.h>
31 #include <FLclLocale.h>
33 namespace Tizen { namespace Locales
37 * @class LocaleManager
38 * @brief This class is used for the %LocaleManager identification.
42 * @final This class is not intended for extension.
44 * The %LocaleManager class helps application programmers handle the system locale information of the device. Each device system has at least 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);
84 DateTime dateTime(2009, 2, 24, 15, 22, 00);
85 pDateTimeFormatter->Format(dateTime, formattedString);
87 // Gets the currency symbol that is localized.
88 NumberFormatter* pCurrencyFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
90 pCurrencyFormatter->Format(inputNumber, formattedString);
93 delete pNumberFormatter;
94 delete pDateTimeFormatter;
95 delete pCurrencyFormatter;
100 * The following example demonstrates how to use the %LocaleManager class to get a list of all the available locales from the system.
105 #include <FLocales.h>
107 using namespace Tizen::Base;
108 using namespace Tizen::Locales;
111 LocaleApp::LocaleExample2(void)
113 LocaleManager localeManager;
114 localeManager.Construct();
116 IList* pAvailableLocales = localeManager.GetAvailableLocalesN();
117 if (pAvailableLocales)
119 for (int i = 0; i < pAvailableLocales->GetCount(); i++)
121 Locale* pLocale = (Locale*) (pAvailableLocales->GetAt(i));
123 String languageCodeString = pLocale->GetLanguageCodeString();
124 String countryCodeString = pLocale->GetCountryCodeString();
125 String variantCodString = pLocale->GetVariantCodeString();
136 class _OSP_EXPORT_ LocaleManager
137 : public Tizen::Base::Object
141 * This is the default constructor for this class. @n
142 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
152 * This is the destructor for this class. @n
153 * This destructor overrides Tizen::Base::Object::~Object().
157 virtual ~LocaleManager(void);
160 * Initializes this instance of %LocaleManager.
164 * @return An error code
165 * @exception E_SUCCESS The method is successful.
166 * @exception E_OUT_OF_MEMORY The memory is insufficient.
168 result Construct(void);
172 * Gets the system locale of the device.
176 * @return An instance of Locale
177 * @exception E_SUCCESS The method is successful.
178 * @exception E_SYSTEM A system error has occurred.
179 * @remarks The specific error code can be accessed using the GetLastResult() method.
180 * The resulting Locale instance is Locale (LANGUAGE_INVALID, COUNTRY_INVALID).
182 Locale GetSystemLocale(void) const;
186 * Gets a list of all the available locales.
190 * @return A list of Locale instances, @n
191 * else @c null if the method fails
192 * @exception E_SUCCESS The method is successful.
193 * @exception E_OUT_OF_MEMORY The memory is insufficient.
194 * @exception E_SYSTEM A system error has occurred.
195 * @remarks The IList returned contains the list of all the locales installed on the system.
196 * The specific error code can be accessed using the GetLastResult() method.
198 Tizen::Base::Collection::IList* GetAvailableLocalesN(void) const;
202 * Gets the currently selected language of the device by a user from the user setting menu.
206 * @return An instance of Tizen::Base::String (ISO 639-2 code format), @n
207 * else empty string if the method fails
208 * @exception E_SUCCESS The method is successful.
209 * @remarks The specific error code can be accessed using the GetLastResult() method.
211 Tizen::Base::String GetSelectedLanguage(void) const;
215 * Gets a list of all the available languages supported by the device, which can be different according to the target country/region of the device.
219 * @return A list of Tizen::Base::String instances (ISO 639-2 code format), @n
220 * else @c null if the method fails
221 * @exception E_SUCCESS The method is successful.
222 * @exception E_OUT_OF_MEMORY The memory is insufficient.
223 * @exception E_SYSTEM A system error has occurred.
224 * @remarks The specific error code can be accessed using the GetLastResult() method.
226 Tizen::Base::Collection::IList* GetAvailableLanguagesN(void) const;
230 * Gets a list of all the available time zone IDs.
234 * @return A list of Tizen::Base::String instances, @n
235 * else @c null if the method fails
236 * @exception E_SUCCESS The method is successful.
237 * @exception E_OUT_OF_MEMORY The memory is insufficient.
238 * @exception E_SYSTEM A system error has occurred.
239 * @remarks The specific error code can be accessed using the GetLastResult() method.
241 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(void) const;
245 * Gets a list of all the available time zone IDs with the specified Greenwich Mean Time (GMT) offset for this time zone.
249 * @return A list of Tizen::Base::String instances, @n
250 * else @c null if the method fails
251 * @param[in] rawOffset The specified GMT offset for this time zone (Daylight Saving Time (DST) is not considered) @n
252 * The value of @c rawOffset is in minutes.
253 * @exception E_SUCCESS The method is successful.
254 * @exception E_OUT_OF_MEMORY The memory is insufficient.
255 * @exception E_SYSTEM A system error has occurred.
256 * @remarks The specific error code can be accessed using the GetLastResult() method.
257 * If there are no time zones for the specified GMT offset, an empty list is returned.
259 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(int rawOffset) const;
263 * Gets the default system time zone.
267 * @return The default system time zone, @n
268 * else the time zone name is an empty string and the offset is @c -1 if the method fails
269 * @exception E_SUCCESS The method is successful.
270 * @remarks The specific error code can be accessed using the GetLastResult() method.
272 TimeZone GetSystemTimeZone(void) const;
276 * Checks whether the specified instance of Locale is supported.
280 * @return An error code
281 * @param[in] locale An instance of Locale
282 * @param[out] isSupportedLocale The flag for checking the supported locale
283 * @exception E_SUCCESS The method is successful.
285 result IsSupportedLocale(const Locale& locale, bool& isSupportedLocale);
289 * The implementation of this copy constructor is intentionally blank and declared as private to
290 * prohibit copying of objects.
292 LocaleManager(const LocaleManager& localeManager);
295 * The implementation of this copy assignment operator is intentionally blank and declared as private
296 * to prohibit copying of objects.
298 LocaleManager& operator =(const LocaleManager& localeManager);
300 friend class _LocaleManagerImpl;
301 class _LocaleManagerImpl* __pLocaleManagerImpl;
306 #endif //_FLCL_LOCALE_MANAGER_H_