[Issue#] N/A
[Feature] New LanguageTagsProvider API: method that
allows to add widget default locale to current
language tags list
[Cause] Localization related refactoring in WRT
[Solution] N/A
[Verification] Build package. Additional
unit tests will be provided.
Change-Id: Ic3a17a79ba493d1e3e523b352bc1a1f6d67c0889
void resetLanguageTags();
/*
void resetLanguageTags();
/*
+ * Adds default widget locales to language tags if
+ * it doesn't exist within actual tags.
+ * Default locales i added:
+ * - at the beginning if less then 2 tags exists on list
+ * - just before empty ("") locales - pre-last position
+ * - at the end if last position is not empty locale
+ */
+ void addWidgetDefaultLocales(const DPL::String&);
+
+ /*
* Function converts language tag string (i.e. en-US)
* into locales string (en_US).
*/
* Function converts language tag string (i.e. en-US)
* into locales string (en_US).
*/
this->loadSystemTags();
}
this->loadSystemTags();
}
+void LanguageTagsProvider::addWidgetDefaultLocales(const DPL::String& defaultLocale){
+ if (defaultLocale.size() > 0 &&
+ std::find(m_languageTagsList.begin(), m_languageTagsList.end(), defaultLocale) == m_languageTagsList.end())
+ {
+ if (m_languageTagsList.size() < 2) {
+ m_languageTagsList.push_front(defaultLocale);
+ } else {
+ LanguageTags::iterator placeToInsert = m_languageTagsList.end();
+ --placeToInsert;
+ if (*placeToInsert != L"")
+ {
+ ++placeToInsert;
+ }
+ m_languageTagsList.insert(placeToInsert, defaultLocale);
+ }
+ }
+}
+
DPL::String LanguageTagsProvider::BCP47LanguageTagToLocale(const DPL::String& inLanguageTag)
{
DPL::String languageTag(inLanguageTag);
DPL::String LanguageTagsProvider::BCP47LanguageTagToLocale(const DPL::String& inLanguageTag)
{
DPL::String languageTag(inLanguageTag);