From: Tomasz Iwanek Date: Mon, 12 Aug 2013 11:20:39 +0000 (+0200) Subject: Pkgmgr's wgt backendlib - fixing name locale for package X-Git-Tag: 2.2.1_release~10^2~64 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d68e39ecab8753cb2814239810b7014bb808b1b8;p=framework%2Fweb%2Fwrt-installer.git Pkgmgr's wgt backendlib - fixing name locale for package [Issue#] LINUXWRT-792 / WGL-406 [Bug] Locale isn't correctly dipatched [Cause] Lookup should be done without subtags too (that wasn't fixed when writing LocalisationTagsSingleton). [Solution] Use code from localisation module [Verification] Try to install widget ta-de-004.wgt (located in wrt-extra) from myfiles app (copy file to /opt/usr/media/Others/). Displayed widget name in popup should be "PASS". Change-Id: I4468619e441f32f1d744bba4eba08a8579fbe403 --- diff --git a/src/pkg-manager/backendlib.cpp b/src/pkg-manager/backendlib.cpp index ceca1ba..7995119 100644 --- a/src/pkg-manager/backendlib.cpp +++ b/src/pkg-manager/backendlib.cpp @@ -28,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +45,7 @@ #include #include #include +#include #include "root_parser.h" #include "widget_parser.h" #include "parser_runner.h" @@ -388,43 +388,44 @@ int getWidgetDetailInfoFromPackage(const char* pkgPath, DPL::Optional name; DPL::Optional desc; - DPL::OptionalString defaultLocale = configInfo.defaultlocale; + LanguageTags tags = LanguageTagsProviderSingleton::Instance().getLanguageTags(); - char* language = vconf_get_str(VCONFKEY_LANGSET); + auto toLowerCase = [](const DPL::String & r) + { + DPL::String result; + std::transform(r.begin(), r.end(), std::inserter(result, result.begin()), ::tolower); + return result; + }; - DPL::String inLocaleString = DPL::FromUTF8String(language); - DPL::String locString = inLocaleString.substr( - 0, inLocaleString.find_first_of(L".")); - std::replace(locString.begin(), locString.end(), '_', '-'); + if (!!configInfo.defaultlocale) + { + Locale & dl = *configInfo.defaultlocale; + configInfo.defaultlocale = toLowerCase(dl); + } - FOREACH(localizedData, configInfo.localizedDataSet) + bool found = false; + FOREACH(tag, tags) { - Locale i = localizedData->first; - std::transform( locString.begin(), - locString.end(), - locString.begin(), - ::tolower ); - std::transform( i.begin(), i.end(), i.begin(), ::tolower ); - std::size_t found = locString.find(i); - std::size_t found2 = i.find(locString); - - if (!!defaultLocale) { - if (defaultLocale == i) { + *tag = toLowerCase(*tag); + FOREACH(localizedData, configInfo.localizedDataSet) + { + Locale i = localizedData->first; + i = toLowerCase(i); + + if (!!configInfo.defaultlocale && *configInfo.defaultlocale == i) + { name = localizedData->second.name; desc = localizedData->second.description; + } + if (*tag == i) + { + name = localizedData->second.name; + desc = localizedData->second.description; + found = true; break; } - } else if (found != std::string::npos - || found2 != std::string::npos) { - name = localizedData->second.name; - desc = localizedData->second.description; - break; - } - else { - name = localizedData->second.name; - desc = localizedData->second.description; - continue; } + if(found) break; } if( !name.IsNull()) {