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);
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::Locales;
112 LocaleApp::LocaleExample2(void)
114 LocaleManager localeManager;
115 localeManager.Construct();
117 IList* pAvailableLocales = localeManager.GetAvailableLocalesN();
118 if (pAvailableLocales)
120 for (int i = 0; i < pAvailableLocales->GetCount(); i++)
122 Locale* pLocale = (Locale*) (pAvailableLocales->GetAt(i));
124 String languageCodeString = pLocale->GetLanguageCodeString();
125 String countryCodeString = pLocale->GetCountryCodeString();
126 String variantCodString = pLocale->GetVariantCodeString();
137 class _OSP_EXPORT_ LocaleManager
138 : public Tizen::Base::Object
142 * This is the default constructor for this class. @n
143 * 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.
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 An instance of Locale
178 * @exception E_SUCCESS The method is successful.
179 * @exception E_SYSTEM A system error has occurred.
180 * @remarks The specific error code can be accessed using the GetLastResult() method.
181 * The resulting Locale instance is Locale (LANGUAGE_INVALID, COUNTRY_INVALID).
183 Locale GetSystemLocale(void) const;
187 * Gets a list of all the available locales.
191 * @return A list of Locale instances, @n
192 * else @c null if the method fails
193 * @exception E_SUCCESS The method is successful.
194 * @exception E_OUT_OF_MEMORY The memory is insufficient.
195 * @exception E_SYSTEM A system error has occurred.
196 * @remarks The IList returned contains the list of all the locales installed on the system.
197 * The specific error code can be accessed using the GetLastResult() method.
199 Tizen::Base::Collection::IList* GetAvailableLocalesN(void) const;
203 * Gets the currently selected language of the device by a user from the user setting menu.
207 * @return An instance of Tizen::Base::String (ISO 639-2 code format), @n
208 * else empty string if the method fails
209 * @exception E_SUCCESS The method is successful.
210 * @remarks The specific error code can be accessed using the GetLastResult() method.
212 Tizen::Base::String GetSelectedLanguage(void) const;
216 * 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.
220 * @return A list of Tizen::Base::String instances (ISO 639-2 code format), @n
221 * else @c null if the method fails
222 * @exception E_SUCCESS The method is successful.
223 * @exception E_OUT_OF_MEMORY The memory is insufficient.
224 * @exception E_SYSTEM A system error has occurred.
225 * @remarks The specific error code can be accessed using the GetLastResult() method.
227 Tizen::Base::Collection::IList* GetAvailableLanguagesN(void) const;
231 * Gets a list of all the available time zone IDs.
235 * @return A list of Tizen::Base::String instances, @n
236 * else @c null if the method fails
237 * @exception E_SUCCESS The method is successful.
238 * @exception E_OUT_OF_MEMORY The memory is insufficient.
239 * @exception E_SYSTEM A system error has occurred.
240 * @remarks The specific error code can be accessed using the GetLastResult() method.
242 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(void) const;
246 * Gets a list of all the available time zone IDs with the specified Greenwich Mean Time (GMT) offset for this time zone.
250 * @return A list of Tizen::Base::String instances, @n
251 * else @c null if the method fails
252 * @param[in] rawOffset The specified GMT offset for this time zone (Daylight Saving Time (DST) is not considered) @n
253 * The value of @c rawOffset is in minutes.
254 * @exception E_SUCCESS The method is successful.
255 * @exception E_OUT_OF_MEMORY The memory is insufficient.
256 * @exception E_SYSTEM A system error has occurred.
257 * @remarks The specific error code can be accessed using the GetLastResult() method.
258 * If there are no time zones for the specified GMT offset, an empty list is returned.
260 Tizen::Base::Collection::IList* GetAvailableTimeZonesN(int rawOffset) const;
264 * Gets the default system time zone.
268 * @return The default system time zone, @n
269 * else the time zone name is an empty string and the offset is @c -1 if the method fails
270 * @exception E_SUCCESS The method is successful.
271 * @remarks The specific error code can be accessed using the GetLastResult() method.
273 TimeZone GetSystemTimeZone(void) const;
277 * Checks whether the specified instance of Locale is supported.
281 * @return An error code
282 * @param[in] locale An instance of Locale
283 * @param[out] isSupportedLocale The flag for checking the supported locale
284 * @exception E_SUCCESS The method is successful.
286 result IsSupportedLocale(const Locale& locale, bool& isSupportedLocale);
290 * The implementation of this copy constructor is intentionally blank and declared as private to
291 * prohibit copying of objects.
293 LocaleManager(const LocaleManager& localeManager);
296 * The implementation of this copy assignment operator is intentionally blank and declared as private
297 * to prohibit copying of objects.
299 LocaleManager& operator =(const LocaleManager& localeManager);
301 friend class _LocaleManagerImpl;
302 class _LocaleManagerImpl* __pLocaleManagerImpl;
307 #endif //_FLCL_LOCALE_MANAGER_H_