[LangInfo/AddonManager] Use gui's language for translation in CAddonMgr::GetTranslate...
authorace20022 <ace20022@ymail.com>
Fri, 4 Oct 2013 09:07:58 +0000 (11:07 +0200)
committerace20022 <ace20022@ymail.com>
Tue, 8 Oct 2013 15:55:22 +0000 (17:55 +0200)
xbmc/LangInfo.cpp
xbmc/LangInfo.h
xbmc/addons/AddonManager.cpp

index f9529ec..4aac004 100644 (file)
@@ -53,6 +53,7 @@ CLangInfo::CRegion::CRegion(const CRegion& region)
   m_strDVDAudioLanguage=region.m_strDVDAudioLanguage;
   m_strDVDSubtitleLanguage=region.m_strDVDSubtitleLanguage;
   m_strLangLocaleName = region.m_strLangLocaleName;
+  m_strLangLocaleCodeTwoChar = region.m_strLangLocaleCodeTwoChar;
   m_strRegionLocaleName = region.m_strRegionLocaleName;
 
   m_strDateFormatShort=region.m_strDateFormatShort;
@@ -86,6 +87,7 @@ void CLangInfo::CRegion::SetDefaults()
   m_strDVDAudioLanguage="en";
   m_strDVDSubtitleLanguage="en";
   m_strLangLocaleName = "English";
+  m_strLangLocaleCodeTwoChar = "en";
 
   m_strDateFormatShort="DD/MM/YYYY";
   m_strDateFormatLong="DDDD, D MMMM YYYY";
@@ -270,6 +272,10 @@ bool CLangInfo::Load(const CStdString& strFileName)
     m_languageCodeGeneral = m_defaultRegion.m_strLangLocaleName;
 #endif
 
+  CStdString tmp;
+  if (g_LangCodeExpander.ConvertToTwoCharCode(tmp, m_defaultRegion.m_strLangLocaleName))
+    m_defaultRegion.m_strLangLocaleCodeTwoChar = tmp;
+
   const TiXmlNode *pCharSets = pRootElement->FirstChild("charsets");
   if (pCharSets && !pCharSets->NoChildren())
   {
@@ -512,8 +518,11 @@ const std::string CLangInfo::GetDVDSubtitleLanguage() const
   return code;
 }
 
-const CStdString& CLangInfo::GetLanguageLocale() const
+const std::string CLangInfo::GetLanguageLocale(bool twochar /* = false */) const
 {
+  if (twochar)
+    return m_currentRegion->m_strLangLocaleCodeTwoChar;
+
   return m_currentRegion->m_strLangLocaleName;
 }
 
index b13bd44..ee14706 100644 (file)
@@ -63,7 +63,7 @@ public:
   const CStdString& GetTimeZone() const;
 
   const CStdString& GetRegionLocale() const;
-  const CStdString& GetLanguageLocale() const;
+  const std::string GetLanguageLocale(bool twochar = false) const;
 
   bool ForceUnicodeFont() const { return m_currentRegion->m_forceUnicodeFont; }
 
@@ -144,6 +144,7 @@ protected:
     CStdString m_strDVDAudioLanguage;
     CStdString m_strDVDSubtitleLanguage;
     CStdString m_strLangLocaleName;
+    std::string m_strLangLocaleCodeTwoChar;
     CStdString m_strRegionLocaleName;
     bool m_forceUnicodeFont;
     CStdString m_strName;
index 895b85c..c05e602 100644 (file)
@@ -587,7 +587,7 @@ const char *CAddonMgr::GetTranslatedString(const cp_cfg_element_t *root, const c
     if (strcmp(tag, child.name) == 0)
     { // see if we have a "lang" attribute
       const char *lang = m_cpluff->lookup_cfg_value((cp_cfg_element_t*)&child, "@lang");
-      if (lang && 0 == strcmp(lang,g_langInfo.GetDVDAudioLanguage().c_str()))
+      if (lang && 0 == strcmp(lang,g_langInfo.GetLanguageLocale(true).c_str()))
         return child.value;
       if (!lang || 0 == strcmp(lang, "en"))
         eng = &child;