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/optional.h>
26 #include <dpl/string.h>
27 #include <dpl/singleton.h>
30 typedef std::list<DPL::String> LanguageTags;
32 class LanguageTagsProvider {
36 * Get list of currently set language tags
38 const LanguageTags getLanguageTags() const;
41 * Set new language tags (other than based on system locales)
43 void setLanguageTags(const LanguageTags& taglist );
46 * Set language tags from given locales.
47 * Supported format is: xx[-yy[-zz]][.encoding]
49 void setLanguageTagsFromLocales(const char* locales);
52 * Set language tags based on system language settings
54 void resetLanguageTags();
57 * Adds default widget locales to language tags if
58 * it doesn't exist within actual tags.
59 * Default locales i added:
60 * - at the beginning if less then 2 tags exists on list
61 * - just before empty ("") locales - pre-last position
62 * - at the end if last position is not empty locale
64 void addWidgetDefaultLocales(const DPL::String&);
67 * Function converts language tag string (i.e. en-US)
68 * into locales string (en_US).
70 static DPL::String BCP47LanguageTagToLocale(const DPL::String&);
73 * Function converts locales string (i.e. en_US.UTF-8) into language tag (i.e. en-US)
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 */