${WRT_SRC_DIR}/domain/global_context.cpp
${WRT_SRC_DIR}/domain/widget_data_types.cpp
${WRT_SRC_DIR}/domain/widget_deserialize_model.cpp
- ${WRT_SRC_DIR}/domain/widget_localize_model.cpp
${WRT_SRC_DIR}/domain/localization_setting.cpp
${WRT_SRC_DIR}/domain/widget_model.cpp
${WRT_SRC_DIR}/domain/main_thread.cpp
* @brief Widget deserialization creates WidgetModel from WidgetDAOReadOnly
*/
-#include "widget_localize_model.h"
#include "widget_model.h"
#include <dpl/wrt-dao-ro/widget_dao_read_only.h>
#include <dpl/log/log.h>
+// to apply widget default locales instead of calling localizeWidgetModel()
+#include <dpl/localization/LanguageTagsProvider.h>
+
namespace Domain {
LogDebug("Widget installed - creating model");
model.reset(new WidgetModel(tizenId));
- // Read DAO data
WrtDB::WidgetDAOReadOnly dao(dplTizenId);
-
- // Set localized data
- Domain::localizeWidgetModel(model->defaultlocale.Get());
+ DPL::Optional<DPL::String> defloc = model->defaultlocale.Get();
+ if(!defloc.IsNull())
+ {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+ }
WrtDB::WidgetAccessInfoList widgetAccessInfoList;
// widgetAccessInfoList is output parameter
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file widget_localize_model.cpp
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version 1.0
- * @brief Widget localize localizes WidgetModel from system configuration
- */
-
-#include <dpl/foreach.h>
-#include <dpl/log/log.h>
-#include <dpl/optional_typedefs.h>
-#include <dpl/localization/LanguageTagsProvider.h>
-
-namespace Domain {
-
-//TODO this should be moved and renamed in LanguageTagsProviderSingleton
-void localizeWidgetModel(const DPL::OptionalString& defaultLocale)
-{
- LogDebug("Default locale for widget: " << defaultLocale);
- LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
- if (!!defaultLocale &&
- std::find(tags.begin(), tags.end(), *defaultLocale) == tags.end())
- {
- if (tags.size() < 2) {
- tags.push_front(*defaultLocale);
- } else {
- LanguageTags::iterator placeToInsert = tags.end();
- --placeToInsert;
- if (*placeToInsert != L"") { ++placeToInsert; }
- tags.insert(placeToInsert, *defaultLocale);
- }
- }
- LogDebug("Setting runtime widget locale:");
- FOREACH(it, tags) {
- LogDebug("Locale: " << *it);
- }
- LanguageTagsProviderSingleton::Instance().setLanguageTags(tags);
-}
-
-} //Namespace Domain
+++ /dev/null
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-/**
- * @file widget_localize_model.h
- * @author Piotr Marcinkiewicz (p.marcinkiew@samsung.com)
- * @version 1.0
- * @brief Widget localization localizes WidgetModel from current settings
- */
-#ifndef WRT_ENGINE_SRC_DOMAIN_WIDGET_LOCALIZE_MODEL_H_
-#define WRT_ENGINE_SRC_DOMAIN_WIDGET_LOCALIZE_MODEL_H_
-
-#include <dpl/optional_typedefs.h>
-
-namespace Domain {
-
-/**
- * @brief Localize widget model
- *
- * Function is using localization utils and W3C file localization
- * to process current language settingto enhance widget model with
- * localized properties.
- *
- * @param[in] model
- */
-void localizeWidgetModel(const DPL::OptionalString& defaultLocale);
-
-} //Namespace Domain
-
-#endif // ifndef WRT_ENGINE_SRC_DOMAIN_WIDGET_LOCALIZE_MODEL_H_
-
// reset language tags (create new tags based on system locales)
LanguageTagsProviderSingleton::Instance().resetLanguageTags();
DPL::OptionalString defaultLocale = dao.getDefaultlocale();
- LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
- // check if default widget language exists in language's list
- if (!!defaultLocale &&
- std::find(tags.begin(), tags.end(), *defaultLocale) == tags.end())
+ if(!defaultLocale.IsNull())
{
- if (tags.size() < 2) {
- tags.push_front(*defaultLocale);
- } else {
- LanguageTags::iterator placeToInsert = tags.end();
- --placeToInsert;
- if (*placeToInsert != L"") { ++placeToInsert; }
- tags.insert(placeToInsert, *defaultLocale);
- }
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defaultLocale);
}
+ LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
LogDebug("Current widget locales (language tags):");
FOREACH(it, tags) {
LogDebug("Locale: " << *it);
}
- LanguageTagsProviderSingleton::Instance().setLanguageTags(tags);
+
// ** Language tags setting completed **
if (argScale != "null" && argScale[0] == '_')
#include <common/application_data.h>
#include <core_module.h>
#include <global_logic.h>
-#include <widget_localize_model.h>
#include <localization_setting.h>
#include <widget_deserialize_model.h>
#include <EWebKit2.h>
return;
}
- ADD_PROFILING_POINT("localizeWidgetModel", "start");
m_dao.reset(new WrtDB::WidgetDAOReadOnly(DPL::FromASCIIString(m_tizenId)));
- Domain::localizeWidgetModel(m_dao->getDefaultlocale());
- ADD_PROFILING_POINT("localizeWidgetModel", "stop");
+ DPL::Optional<DPL::String> defloc = m_dao->getDefaultlocale();
+ if(!defloc.IsNull())
+ {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+ }
+
LocalizationSetting::SetLanguageChangedCallback(
languageChangedCallback, this);
int WrtClient::languageChangedCallback(void *data)
{
LogDebug("Language Changed");
+ if(!data)
+ return 0;
WrtClient* wrtClient = static_cast<WrtClient*>(data);
+ if(!(wrtClient->m_dao))
+ return 0;
- LanguageTags oldtags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
// reset function fetches system locales and recreates language tags
LanguageTagsProviderSingleton::Instance().resetLanguageTags();
- LanguageTags newtags = LanguageTagsProviderSingleton::Instance().getLanguageTags();
-
- // check whether LanguageTags changed or not
- if (oldtags != newtags) {
- // update localized data
- Domain::localizeWidgetModel(wrtClient->m_dao->getDefaultlocale());
+ // widget default locales are added to language tags below
+ DPL::OptionalString defloc = wrtClient->m_dao->getDefaultlocale();
+ if(!defloc.IsNull())
+ {
+ LanguageTagsProviderSingleton::Instance().addWidgetDefaultLocales(*defloc);
+ }
- if (true == wrtClient->m_launched &&
- wrtClient->m_widgetState != WidgetState_Stopped) {
- wrtClient->m_widget->ReloadStartPage();
- }
+ if (wrtClient->m_launched &&
+ wrtClient->m_widgetState != WidgetState_Stopped) {
+ wrtClient->m_widget->ReloadStartPage();
}
return 0;
}