Fix keymap.
[vuplus_xbmc] / xbmc / LangInfo.cpp
index 2b65319..3f2e04f 100644 (file)
@@ -20,6 +20,7 @@
 
 #include "LangInfo.h"
 #include "Application.h"
+#include "ApplicationMessenger.h"
 #include "FileItem.h"
 #include "Util.h"
 #include "filesystem/Directory.h"
@@ -27,7 +28,7 @@
 #include "guilib/LocalizeStrings.h"
 #include "pvr/PVRManager.h"
 #include "settings/AdvancedSettings.h"
-#include "settings/Setting.h"
+#include "settings/lib/Setting.h"
 #include "settings/Settings.h"
 #include "utils/CharsetConverter.h"
 #include "utils/log.h"
@@ -196,6 +197,7 @@ void CLangInfo::CRegion::SetGlobalLocale()
 
   locale::global(current_locale);
 #endif
+  g_charsetConverter.resetSystemCharset();
   CLog::Log(LOGINFO, "global locale set to %s", strLocale.c_str());
 }
 
@@ -242,7 +244,7 @@ bool CLangInfo::Load(const std::string& strFileName, bool onlyCheckLanguage /*=
   }
 
   TiXmlElement* pRootElement = xmlDoc.RootElement();
-  if (pRootElement->ValueStr() == "language")
+  if (pRootElement->ValueStr() != "language")
   {
     CLog::Log(onlyCheckLanguage ? LOGDEBUG : LOGERROR, "%s Doesn't contain <language>", strFileName.c_str());
     return false;
@@ -318,7 +320,7 @@ bool CLangInfo::Load(const std::string& strFileName, bool onlyCheckLanguage /*=
     {
       CRegion region(m_defaultRegion);
       region.m_strName=pRegion->Attribute("name");
-      if (region.m_strName.IsEmpty())
+      if (region.m_strName.empty())
         region.m_strName="N/A";
 
       if (pRegion->Attribute("locale"))
@@ -372,6 +374,7 @@ bool CLangInfo::Load(const std::string& strFileName, bool onlyCheckLanguage /*=
       SetCurrentRegion(strName);
     }
   }
+  g_charsetConverter.reinitCharsetsFromSettings();
 
   if (!onlyCheckLanguage)
     LoadTokens(pRootElement->FirstChild("sorttokens"), g_advancedSettings.m_vecTokens);
@@ -397,7 +400,7 @@ void CLangInfo::LoadTokens(const TiXmlNode* pTokens, vector<CStdString>& vecToke
         strSep = pToken->Attribute("separators");
       if (pToken->FirstChild() && pToken->FirstChild()->Value())
       {
-        if (strSep.IsEmpty())
+        if (strSep.empty())
           vecTokens.push_back(pToken->FirstChild()->Value());
         else
           for (unsigned int i=0;i<strSep.size();++i)
@@ -454,15 +457,13 @@ bool CLangInfo::SetLanguage(const std::string &strLanguage)
       CLog::Log(LOGERROR, "No ttf font found but needed: %s", strFontSet.c_str());
   }
 
-  g_charsetConverter.reset();
-
   if (!g_localizeStrings.Load("special://xbmc/language/", strLanguage))
     return false;
 
   // also tell our weather and skin to reload as these are localized
   g_weatherManager.Refresh();
   g_PVRManager.LocalizationChanged();
-  g_application.ReloadSkin();
+  CApplicationMessenger::Get().ExecBuiltIn("ReloadSkin", false);
 
   return true;
 }
@@ -481,9 +482,12 @@ const CStdString& CLangInfo::GetAudioLanguage() const
   return m_languageCodeGeneral;
 }
 
-void CLangInfo::SetAudioLanguage(const CStdString &language)
+void CLangInfo::SetAudioLanguage(const std::string& language)
 {
-  if (language.empty() || !g_LangCodeExpander.ConvertToThreeCharCode(m_audioLanguage, language))
+  if (language.empty()
+    || StringUtils::EqualsNoCase(language, "default")
+    || StringUtils::EqualsNoCase(language, "original")
+    || !g_LangCodeExpander.ConvertToThreeCharCode(m_audioLanguage, language))
     m_audioLanguage.clear();
 }
 
@@ -496,9 +500,12 @@ const CStdString& CLangInfo::GetSubtitleLanguage() const
   return m_languageCodeGeneral;
 }
 
-void CLangInfo::SetSubtitleLanguage(const CStdString &language)
+void CLangInfo::SetSubtitleLanguage(const std::string& language)
 {
-  if (language.empty() || !g_LangCodeExpander.ConvertToThreeCharCode(m_subtitleLanguage, language))
+  if (language.empty()
+    || StringUtils::EqualsNoCase(language, "default")
+    || StringUtils::EqualsNoCase(language, "original")
+    || !g_LangCodeExpander.ConvertToThreeCharCode(m_subtitleLanguage, language))
     m_subtitleLanguage.clear();
 }