Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #3375 from ace20022/langinfo

[Langinfo] Use preferred audio/subtitle language for dvds and blurays.
  • Loading branch information...
commit c3ff40f693d0bc07de0785581b52710bc83e7c4e 2 parents b4c32ba + b994301
@ace20022 ace20022 authored
View
35 xbmc/LangInfo.cpp
@@ -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())
{
@@ -483,25 +489,40 @@ void CLangInfo::SetSubtitleLanguage(const CStdString &language)
}
// two character codes as defined in ISO639
-const CStdString& CLangInfo::GetDVDMenuLanguage() const
+const std::string CLangInfo::GetDVDMenuLanguage() const
{
- return m_currentRegion->m_strDVDMenuLanguage;
+ CStdString code;
+ if (!g_LangCodeExpander.ConvertToTwoCharCode(code, m_currentRegion->m_strLangLocaleName))
+ code = m_currentRegion->m_strDVDMenuLanguage;
+
+ return code;
}
// two character codes as defined in ISO639
-const CStdString& CLangInfo::GetDVDAudioLanguage() const
+const std::string CLangInfo::GetDVDAudioLanguage() const
{
- return m_currentRegion->m_strDVDAudioLanguage;
+ CStdString code;
+ if (!g_LangCodeExpander.ConvertToTwoCharCode(code, m_audioLanguage))
+ code = m_currentRegion->m_strDVDAudioLanguage;
+
+ return code;
}
// two character codes as defined in ISO639
-const CStdString& CLangInfo::GetDVDSubtitleLanguage() const
+const std::string CLangInfo::GetDVDSubtitleLanguage() const
{
- return m_currentRegion->m_strDVDSubtitleLanguage;
+ CStdString code;
+ if (!g_LangCodeExpander.ConvertToTwoCharCode(code, m_subtitleLanguage))
+ code = m_currentRegion->m_strDVDSubtitleLanguage;
+
+ 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;
}
View
9 xbmc/LangInfo.h
@@ -57,13 +57,13 @@ class CLangInfo : public ISettingCallback
// or a language name in english (as used by XBMC)
void SetSubtitleLanguage(const CStdString &language);
- const CStdString& GetDVDMenuLanguage() const;
- const CStdString& GetDVDAudioLanguage() const;
- const CStdString& GetDVDSubtitleLanguage() const;
+ const std::string GetDVDMenuLanguage() const;
+ const std::string GetDVDAudioLanguage() const;
+ const std::string GetDVDSubtitleLanguage() const;
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 @@ class CLangInfo : public ISettingCallback
CStdString m_strDVDAudioLanguage;
CStdString m_strDVDSubtitleLanguage;
CStdString m_strLangLocaleName;
+ std::string m_strLangLocaleCodeTwoChar;
CStdString m_strRegionLocaleName;
bool m_forceUnicodeFont;
CStdString m_strName;
View
2  xbmc/addons/AddonManager.cpp
@@ -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;
Please sign in to comment.
Something went wrong with that request. Please try again.