Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

dvdplayer: try to find a subtitle that matches the preferred subtitle…

… language setting when starting a video
  • Loading branch information...
commit 3ba18fbf87055f6686b097bf15cfe56510e8ac07 1 parent 4847bc7
@Montellese Montellese authored
View
4 language/English/strings.po
@@ -1032,6 +1032,10 @@ msgstr ""
#: id:285
msgid "Preferred audio language"
+msgstr ""
+
+#: id:286
+msgid "Preferred subtitle language"
msgstr ""
#: id:287
View
15 xbmc/LangInfo.cpp
@@ -401,6 +401,21 @@ void CLangInfo::SetAudioLanguage(const CStdString &language)
m_audioLanguage.clear();
}
+// three char language code (not win32 specific)
+const CStdString& CLangInfo::GetSubtitleLanguage() const
+{
+ if (!m_subtitleLanguage.empty())
+ return m_subtitleLanguage;
+
+ return m_languageCodeGeneral;
+}
+
+void CLangInfo::SetSubtitleLanguage(const CStdString &language)
+{
+ if (language.empty() || !g_LangCodeExpander.ConvertToThreeCharCode(m_subtitleLanguage, language))
+ m_subtitleLanguage.clear();
+}
+
// two character codes as defined in ISO639
const CStdString& CLangInfo::GetDVDMenuLanguage() const
{
View
8 xbmc/LangInfo.h
@@ -45,6 +45,13 @@ class CLangInfo
// or a three char language code
// or a language name in english (as used by XBMC)
void SetAudioLanguage(const CStdString &language);
+
+ // three char language code (not win32 specific)
+ const CStdString& GetSubtitleLanguage() const;
+ // language can either be a two char language code as defined in ISO639
+ // or a three char language code
+ // or a language name in english (as used by XBMC)
+ void SetSubtitleLanguage(const CStdString &language);
const CStdString& GetDVDMenuLanguage() const;
const CStdString& GetDVDAudioLanguage() const;
@@ -152,6 +159,7 @@ class CLangInfo
CRegion m_defaultRegion; // default, will be used if no region available via langinfo.xml
CStdString m_audioLanguage;
+ CStdString m_subtitleLanguage;
// this is the general (not win32-specific) three char language code
CStdString m_languageCodeGeneral;
};
View
13 xbmc/cores/dvdplayer/DVDPlayer.cpp
@@ -167,12 +167,25 @@ static bool PredicateSubtitlePriority(const SelectionStream& lh, const Selection
PREDICATE_RETURN(lh.type_index == g_settings.m_currentVideoSettings.m_SubtitleStream
, rh.type_index == g_settings.m_currentVideoSettings.m_SubtitleStream);
+ CStdString subtitle_language = g_langInfo.GetSubtitleLanguage();
+ if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original"))
+ {
+ PREDICATE_RETURN((lh.source == STREAM_SOURCE_DEMUX_SUB || lh.source == STREAM_SOURCE_TEXT) && subtitle_language.Equals(lh.language.c_str())
+ , (rh.source == STREAM_SOURCE_DEMUX_SUB || rh.source == STREAM_SOURCE_TEXT) && subtitle_language.Equals(rh.language.c_str()));
+ }
+
PREDICATE_RETURN(lh.source == STREAM_SOURCE_DEMUX_SUB
, rh.source == STREAM_SOURCE_DEMUX_SUB);
PREDICATE_RETURN(lh.source == STREAM_SOURCE_TEXT
, rh.source == STREAM_SOURCE_TEXT);
+ if(!g_guiSettings.GetString("locale.subtitlelanguage").Equals("original"))
+ {
+ PREDICATE_RETURN(subtitle_language.Equals(lh.language.c_str())
+ , subtitle_language.Equals(rh.language.c_str()));
+ }
+
PREDICATE_RETURN(lh.flags & CDemuxStream::FLAG_DEFAULT
, rh.flags & CDemuxStream::FLAG_DEFAULT);
View
7 xbmc/settings/GUISettings.cpp
@@ -847,6 +847,7 @@ void CGUISettings::Initialize()
#endif
AddSeparator(loc, "locale.sep3");
AddString(loc, "locale.audiolanguage", 285, "original", SPIN_CONTROL_TEXT);
+ AddString(loc, "locale.subtitlelanguage", 286, "original", SPIN_CONTROL_TEXT);
CSettingsCategory* fl = AddCategory(7, "filelists", 14081);
AddBool(fl, "filelists.showparentdiritems", 13306, true);
@@ -1271,6 +1272,12 @@ void CGUISettings::LoadXML(TiXmlElement *pRootElement, bool hideSettings /* = fa
g_langInfo.SetAudioLanguage(streamLanguage);
else
g_langInfo.SetAudioLanguage("");
+
+ streamLanguage = GetString("locale.subtitlelanguage");
+ if (!streamLanguage.Equals("original") && !streamLanguage.Equals("default"))
+ g_langInfo.SetSubtitleLanguage(streamLanguage);
+ else
+ g_langInfo.SetSubtitleLanguage("");
}
void CGUISettings::LoadFromXML(TiXmlElement *pRootElement, mapIter &it, bool advanced /* = false */)
View
25 xbmc/settings/GUIWindowSettingsCategory.cpp
@@ -440,7 +440,7 @@ void CGUIWindowSettingsCategory::CreateSettings()
FillInLanguages(pSetting);
continue;
}
- else if (strSetting.Equals("locale.audiolanguage"))
+ else if (strSetting.Equals("locale.audiolanguage") || strSetting.Equals("locale.subtitlelanguage"))
{
AddSetting(pSetting, group->GetWidth(), iControlID);
vector<CStdString> languages;
@@ -1483,6 +1483,29 @@ void CGUIWindowSettingsCategory::OnSettingChanged(CBaseSettingControl *pSettingC
}
}
}
+ else if (strSetting.Equals("locale.subtitlelanguage"))
+ { // new subtitle language chosen...
+ CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
+ CGUISpinControlEx *pControl = (CGUISpinControlEx *)GetControl(pSettingControl->GetID());
+ int iLanguage = pControl->GetValue();
+ if (iLanguage < 2)
+ {
+ if (iLanguage < 1)
+ g_guiSettings.SetString(strSetting, "original");
+ else
+ g_guiSettings.SetString(strSetting, "default");
+ g_langInfo.SetSubtitleLanguage("");
+ }
+ else
+ {
+ CStdString strLanguage = pControl->GetCurrentLabel();
+ if (strLanguage != pSettingString->GetData())
+ {
+ g_guiSettings.SetString(strSetting, strLanguage);
+ g_langInfo.SetSubtitleLanguage(strLanguage);
+ }
+ }
+ }
else if (strSetting.Equals("locale.language"))
{ // new language chosen...
CSettingString *pSettingString = (CSettingString *)pSettingControl->GetSetting();
Please sign in to comment.
Something went wrong with that request. Please try again.