Skip to content
This repository
Browse code

[DVD/OMXPlayer] Always use the first entry of a language code in the …

…mixed ISO 639-2 T/B code table.
  • Loading branch information...
commit 44cf328580166b081036c60f4fda8b46e21db113 1 parent a513fe9
Andreas Zelend authored July 05, 2013
14  xbmc/cores/dvdplayer/DVDPlayer.cpp
@@ -326,7 +326,7 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
326 326
       DVDNavStreamInfo info;
327 327
       nav->GetAudioStreamInfo(i, info);
328 328
       s.name     = info.name;
329  
-      s.language = info.language;
  329
+      s.language = g_LangCodeExpander.ConvertToISO6392T(info.language);
330 330
       s.channels = info.channels;
331 331
       Update(s);
332 332
     }
@@ -345,7 +345,7 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
345 345
       DVDNavStreamInfo info;
346 346
       nav->GetSubtitleStreamInfo(i, info);
347 347
       s.name     = info.name;
348  
-      s.language = info.language;
  348
+      s.language = g_LangCodeExpander.ConvertToISO6392T(info.language);
349 349
       Update(s);
350 350
     }
351 351
   }
@@ -370,15 +370,7 @@ void CSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
370 370
       s.source   = source;
371 371
       s.type     = stream->type;
372 372
       s.id       = stream->iId;
373  
-      s.language = stream->language;
374  
-
375  
-      if (s.language.length() == 2)
376  
-      {
377  
-        CStdString lang;
378  
-        g_LangCodeExpander.ConvertToThreeCharCode(lang, stream->language);
379  
-        s.language = lang;
380  
-      }
381  
-
  373
+      s.language = g_LangCodeExpander.ConvertToISO6392T(stream->language);
382 374
       s.flags    = stream->flags;
383 375
       s.filename = demuxer->GetFileName();
384 376
       stream->GetStreamName(s.name);
14  xbmc/cores/omxplayer/OMXPlayer.cpp
@@ -365,7 +365,7 @@ void COMXSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
365 365
       DVDNavStreamInfo info;
366 366
       nav->GetAudioStreamInfo(i, info);
367 367
       s.name     = info.name;
368  
-      s.language = info.language;
  368
+      s.language = g_LangCodeExpander.ConvertToISO6392T(info.language);
369 369
       s.channels = info.channels;
370 370
       Update(s);
371 371
     }
@@ -384,7 +384,7 @@ void COMXSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
384 384
       DVDNavStreamInfo info;
385 385
       nav->GetSubtitleStreamInfo(i, info);
386 386
       s.name     = info.name;
387  
-      s.language = info.language;
  387
+      s.language = g_LangCodeExpander.ConvertToISO6392T(info.language);
388 388
       Update(s);
389 389
     }
390 390
   }
@@ -409,15 +409,7 @@ void COMXSelectionStreams::Update(CDVDInputStream* input, CDVDDemux* demuxer)
409 409
       s.source   = source;
410 410
       s.type     = stream->type;
411 411
       s.id       = stream->iId;
412  
-      s.language = stream->language;
413  
-
414  
-      if (s.language.length() == 2)
415  
-      {
416  
-        CStdString lang;
417  
-        g_LangCodeExpander.ConvertToThreeCharCode(lang, stream->language);
418  
-        s.language = lang;
419  
-      }
420  
-
  412
+      s.language = g_LangCodeExpander.ConvertToISO6392T(stream->language);
421 413
       s.flags    = stream->flags;
422 414
       s.filename = demuxer->GetFileName();
423 415
       stream->GetStreamName(s.name);
11  xbmc/utils/LangCodeExpander.cpp
@@ -479,6 +479,17 @@ bool CLangCodeExpander::CompareLangCodes(const CStdString& code1, const CStdStri
479 479
   return expandedLang1.Equals(expandedLang2);
480 480
 }
481 481
 
  482
+CStdString CLangCodeExpander::ConvertToISO6392T(const CStdString& lang)
  483
+{
  484
+  CStdString two, three;
  485
+  if (ConvertToTwoCharCode(two, lang))
  486
+  {
  487
+    if (ConvertToThreeCharCode(three, two))
  488
+      return three;
  489
+  }
  490
+  return lang;
  491
+}
  492
+
482 493
 extern const LCENTRY g_iso639_1[144] =
483 494
 {
484 495
   { MAKECODE('\0','\0','c','c'), "Closed Caption" },
8  xbmc/utils/LangCodeExpander.h
@@ -65,6 +65,14 @@ class CLangCodeExpander
65 65
   *   \return true if the conversion succeeded, false otherwise. 
66 66
   */ 
67 67
   bool ConvertToTwoCharCode(CStdString& code, const CStdString& lang);
  68
+
  69
+  /** \brief Converts a language given as 2-Char (ISO 639-1),
  70
+  *          3-Char (ISO 639-2/T or ISO 639-2/B),
  71
+  *          or full english name string to a 3-Char ISO 639-2/T code.
  72
+  *   \param[in] lang The language that should be converted.
  73
+  *   \return The 3-Char ISO 639-2/T code of lang if that code exists, lang otherwise.
  74
+  */
  75
+  CStdString ConvertToISO6392T(const CStdString& lang);
68 76
 #ifdef TARGET_WINDOWS
69 77
   bool ConvertTwoToThreeCharCode(CStdString& strThreeCharCode, const CStdString& strTwoCharCode, bool localeHack = false);
70 78
   bool ConvertToThreeCharCode(CStdString& strThreeCharCode, const CStdString& strCharCode, bool localeHack = false);

3 notes on commit 44cf328

Rainer Hochecker
Collaborator

not completely sure but looks like this change is responsible for having masses of those in the log:
ERROR: unable to load special://xbmc/language//langinfo.xml: Failed to open file at line 0

Andreas Zelend
Collaborator

masses? Will have a look

Andreas Zelend
Collaborator

@FernetMenta got it, this happens if the language (code) is "", will add an early return to the lookup methods.

Please sign in to comment.
Something went wrong with that request. Please try again.