2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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.
17 * @file LanguageTagsProvider.h
18 * @author Marcin Kaminski (marcin.ka@samsung.com)
22 #ifndef LANGUAGETAGSPROVIDER_H
23 #define LANGUAGETAGSPROVIDER_H
25 #include <dpl/string.h>
26 #include <dpl/singleton.h>
29 typedef std::list<DPL::String> LanguageTags;
31 class LanguageTagsProvider
35 * Get list of currently set language tags
37 const LanguageTags getLanguageTags() const;
40 * Set new language tags (other than based on system locales)
42 void setLanguageTags(const LanguageTags& taglist);
45 * Set language tags from given locales.
46 * Supported format is: xx[-yy[-zz]][.encoding]
48 void setLanguageTagsFromLocales(const char* locales);
51 * Set language tags based on system language settings
53 void resetLanguageTags();
56 * Adds default widget locales to language tags if
57 * it doesn't exist within actual tags.
58 * Default locales i added:
59 * - at the beginning if less then 2 tags exists on list
60 * - just before empty ("") locales - pre-last position
61 * - at the end if last position is not empty locale
63 void addWidgetDefaultLocales(const DPL::String&);
66 * Function converts language tag string (i.e. en-US)
67 * into locales string (en_US).
69 static DPL::String BCP47LanguageTagToLocale(const DPL::String&);
72 * Function converts locales string (i.e. en_US.UTF-8) into language tag
75 static DPL::String LocaleToBCP47LanguageTag(const DPL::String&);
78 friend class DPL::Singleton<LanguageTagsProvider>;
80 LanguageTags m_languageTagsList;
82 LanguageTagsProvider();
83 virtual ~LanguageTagsProvider();
85 void loadSystemTags();
86 void createTagsFromLocales(const char* language);
89 typedef DPL::Singleton<LanguageTagsProvider> LanguageTagsProviderSingleton;
91 #endif /* LANGUAGETAGSPROVIDER_H */