Save domain info for MultiLanguage 00/219600/2
authorJusung Son <jusung07.son@samsung.com>
Fri, 6 Dec 2019 08:14:55 +0000 (17:14 +0900)
committerjusung son <jusung07.son@samsung.com>
Thu, 19 Dec 2019 06:43:12 +0000 (06:43 +0000)
Change-Id: I3b40d720d2b9b69763402f341f577da8db4360a7
Signed-off-by: Jusung Son <jusung07.son@samsung.com>
notification-ex/ex_util.cc
notification-ex/multi_language.cc
notification-ex/multi_language_implementation.h

index d2813de..07e5b55 100644 (file)
@@ -145,16 +145,16 @@ string GetDomainName() {
 }
 
 string GetLocaleDirectory() {
-  string pkgid = GetPkgId();
-  if (pkgid.empty())
-    return "";
-
   static string locale_directory = "";
   if (!locale_directory.empty()) {
     LOGI("locale_directory(%s)", locale_directory.c_str());
     return locale_directory;
   }
 
+  string pkgid = GetPkgId();
+  if (pkgid.empty())
+    return "";
+
   package_info_h package_info;
   int err = package_info_create(pkgid.c_str(), &package_info);
   if (err != PACKAGE_MANAGER_ERROR_NONE) {
index 0d08c2b..1cc0fb1 100644 (file)
@@ -33,6 +33,8 @@
 #define MULTI_LANGUAGE_FORMAT_KEY "__MULTI_LANGUAGE_FORMAT_KEY__"
 #define MULTI_LANGUAGE_ARGS_KEY "__MULTI_LANGUAGE_ARGS_KEY__"
 #define MULTI_LANGUAGE_TRANSLATED_KEY "__MULTI_LANGUAGE_TRANSLATED_KEY__"
+#define MULTI_LANGUAGE_DOMAIN_KEY "__MULTI_LANGUAGE_DOMAIN_KEY__"
+#define MULTI_LANGUAGE_LOCALE_KEY "__MULTI_LANGUAGE_LOCALE_KEY__"
 
 using namespace std;
 using namespace tizen_base;
@@ -72,6 +74,8 @@ Bundle MultiLanguage::Serialize() const {
   b.Add(MULTI_LANGUAGE_FORMAT_KEY, impl_->format_);
   b.Add(MULTI_LANGUAGE_ARGS_KEY, impl_->args_);
   b.Add(MULTI_LANGUAGE_TRANSLATED_KEY, impl_->translated_);
+  b.Add(MULTI_LANGUAGE_DOMAIN_KEY, impl_->domain_name_);
+  b.Add(MULTI_LANGUAGE_LOCALE_KEY, impl_->locale_directory_);
   return b;
 }
 
@@ -80,10 +84,17 @@ void MultiLanguage::Deserialize(Bundle b) {
   impl_->format_ = b.GetString(MULTI_LANGUAGE_FORMAT_KEY);
   impl_->args_ = b.GetStringArray(MULTI_LANGUAGE_ARGS_KEY);
   impl_->translated_ = b.GetString(MULTI_LANGUAGE_TRANSLATED_KEY);
+  impl_->domain_name_ = b.GetString(MULTI_LANGUAGE_DOMAIN_KEY);
+  impl_->locale_directory_ = b.GetString(MULTI_LANGUAGE_LOCALE_KEY);
 }
 
 void MultiLanguage::UpdateString() {
-  UpdateString(util::GetDomainName(), util::GetLocaleDirectory());
+  if (impl_->domain_name_.empty())
+    impl_->domain_name_ = util::GetDomainName();
+  if (impl_->locale_directory_.empty())
+    impl_->locale_directory_ = util::GetLocaleDirectory();
+
+  UpdateString(impl_->domain_name_, impl_->locale_directory_);
 }
 
 void MultiLanguage::UpdateString(string domain, string locale_directory) {
index 70be1b2..ddacbc3 100644 (file)
@@ -44,6 +44,8 @@ class MultiLanguage::Impl {
   std::string format_;
   std::vector<std::string> args_;
   std::string translated_;
+  std::string domain_name_;
+  std::string locale_directory_;
   MultiLanguage* parent_;
 };