From 978cb20c4fc095d5f12479e39c9201890e3465e0 Mon Sep 17 00:00:00 2001 From: montellese Date: Mon, 23 Feb 2015 09:01:40 +0100 Subject: [PATCH] simplify and document CLangInfo::GetLanguageLocale() --- xbmc/LangInfo.cpp | 7 ++----- xbmc/LangInfo.h | 6 +++++- xbmc/addons/AddonManager.cpp | 2 +- xbmc/addons/GUIWindowAddonBrowser.cpp | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/xbmc/LangInfo.cpp b/xbmc/LangInfo.cpp index 9589a5f7f31d5..dfe4ec3babae9 100644 --- a/xbmc/LangInfo.cpp +++ b/xbmc/LangInfo.cpp @@ -535,12 +535,9 @@ const std::string CLangInfo::GetDVDSubtitleLanguage() const return code; } -const std::string CLangInfo::GetLanguageLocale(bool twochar /* = false */) const +const std::string& CLangInfo::GetLanguageLocale() const { - if (twochar) - return m_currentRegion->m_strLangLocaleCodeTwoChar; - - return m_currentRegion->m_strLangLocaleName; + return m_currentRegion->m_strLangLocaleCodeTwoChar; } const std::string& CLangInfo::GetRegionLocale() const diff --git a/xbmc/LangInfo.h b/xbmc/LangInfo.h index 6c9898c41fde2..0af6f8c86a0a2 100644 --- a/xbmc/LangInfo.h +++ b/xbmc/LangInfo.h @@ -76,7 +76,11 @@ class CLangInfo : public ISettingCallback const std::string& GetTimeZone() const; const std::string& GetRegionLocale() const; - const std::string GetLanguageLocale(bool twochar = false) const; + + /*! + \brief Returns the two character ISO 639-1 language code of the current language. + */ + const std::string& GetLanguageLocale() const; bool ForceUnicodeFont() const { return m_currentRegion->m_forceUnicodeFont; } diff --git a/xbmc/addons/AddonManager.cpp b/xbmc/addons/AddonManager.cpp index 3423b4b5069c9..746a81fcb8c2c 100644 --- a/xbmc/addons/AddonManager.cpp +++ b/xbmc/addons/AddonManager.cpp @@ -631,7 +631,7 @@ std::string 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.GetLanguageLocale(true).c_str())) + if (lang && 0 == strcmp(lang,g_langInfo.GetLanguageLocale().c_str())) return child.value ? child.value : ""; if (!lang || 0 == strcmp(lang, "en")) eng = &child; diff --git a/xbmc/addons/GUIWindowAddonBrowser.cpp b/xbmc/addons/GUIWindowAddonBrowser.cpp index c79f3b76120dd..dde39c6cc08f0 100644 --- a/xbmc/addons/GUIWindowAddonBrowser.cpp +++ b/xbmc/addons/GUIWindowAddonBrowser.cpp @@ -376,7 +376,7 @@ bool CGUIWindowAddonBrowser::GetDirectory(const std::string& strDirectory, while (i < items.Size()) { if (!FilterVar(true, items[i]->GetProperty("Addon.Language"), "en") || - !FilterVar(true, items[i]->GetProperty("Addon.Language"), g_langInfo.GetLanguageLocale(true))) + !FilterVar(true, items[i]->GetProperty("Addon.Language"), g_langInfo.GetLanguageLocale())) { i++; }