The Free Software Media System - Server Backend & API
Fix language display for ISO 639-2-only codes (e.g. mul, und)
Lasath Fernando553f38a2377c
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.csindex bc80c2b405..6fca5bc1ba 100644--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Localizationstring twoCharName = parts[2];if (string.IsNullOrWhiteSpace(twoCharName)){- continue;+ twoCharName = string.Empty;}else if (twoCharName.Contains('-', StringComparison.OrdinalIgnoreCase)){diff --git a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.csindex d3e7b52315..203e72de36 100644--- a/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs+++ b/MediaBrowser.MediaEncoding/Probing/ProbeResultNormalizer.cs@@ -729,6 +729,9 @@ namespace MediaBrowser.MediaEncoding.Probingstream.Type = MediaStreamType.Audio;stream.LocalizedDefault = _localization.GetLocalizedString("Default");stream.LocalizedExternal = _localization.GetLocalizedString("External");+ stream.LocalizedLanguage = !string.IsNullOrEmpty(stream.Language)+ ? _localization.FindLanguageInfo(stream.Language)?.DisplayName+ : null;stream.Channels = streamInfo.Channels;@@ -767,6 +770,9 @@ namespace MediaBrowser.MediaEncoding.Probingstream.LocalizedForced = _localization.GetLocalizedString("Forced");stream.LocalizedExternal = _localization.GetLocalizedString("External");stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");+ stream.LocalizedLanguage = !string.IsNullOrEmpty(stream.Language)+ ? _localization.FindLanguageInfo(stream.Language)?.DisplayName+ : null;if (string.IsNullOrEmpty(stream.Title)){diff --git a/MediaBrowser.Model/Entities/MediaStream.cs b/MediaBrowser.Model/Entities/MediaStream.csindex 11f81ff7d8..4491fb5ace 100644--- a/MediaBrowser.Model/Entities/MediaStream.cs+++ b/MediaBrowser.Model/Entities/MediaStream.cs@@ -5,7 +5,6 @@ using System;using System.Collections.Generic;using System.ComponentModel;using System.Globalization;-using System.Linq;using System.Text;using System.Text.Json.Serialization;using Jellyfin.Data.Enums;diff --git a/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs b/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.csindex e60522bf78..700ac5dced 100644--- a/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs+++ b/tests/Jellyfin.Server.Implementations.Tests/Localization/LocalizationManagerTests.cs@@ -41,7 +41,7 @@ namespace Jellyfin.Server.Implementations.Tests.Localizationawait localizationManager.LoadAll();var cultures = localizationManager.GetCultures().ToList();- Assert.Equal(194, cultures.Count);+ Assert.Equal(496, cultures.Count);var germany = cultures.FirstOrDefault(x => x.TwoLetterISOLanguageName.Equals("de", StringComparison.Ordinal));Assert.NotNull(germany);@@ -99,6 +99,25 @@ namespace Jellyfin.Server.Implementations.Tests.LocalizationAssert.Contains("ger", germany.ThreeLetterISOLanguageNames);}+ [Theory]+ [InlineData("mul", "Multiple languages")]+ [InlineData("und", "Undetermined")]+ [InlineData("mis", "Uncoded languages")]+ [InlineData("zxx", "No linguistic content; Not applicable")]+ public async Task FindLanguageInfo_ISO6392Only_Success(string code, string expectedDisplayName)+ {+ var localizationManager = Setup(new ServerConfiguration+ {+ UICulture = "en-US"+ });+ await localizationManager.LoadAll();++ var culture = localizationManager.FindLanguageInfo(code);+ Assert.NotNull(culture);+ Assert.Equal(expectedDisplayName, culture.DisplayName);+ Assert.Equal(code, culture.ThreeLetterISOLanguageName);+ }+[Fact]public async Task GetParentalRatings_Default_Success(){