Merge pull request #16567 from shocklateboy92/fix/iso639-2-language-display

Fix language display for ISO 639-2-only codes (e.g. mul, und, mis, zxx)
This commit is contained in:
Bond-009
2026-04-11 10:24:48 +02:00
committed by GitHub
4 changed files with 27 additions and 3 deletions

View File

@@ -138,7 +138,7 @@ namespace Emby.Server.Implementations.Localization
string twoCharName = parts[2];
if (string.IsNullOrWhiteSpace(twoCharName))
{
continue;
twoCharName = string.Empty;
}
else if (twoCharName.Contains('-', StringComparison.OrdinalIgnoreCase))
{

View File

@@ -729,6 +729,9 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.Type = MediaStreamType.Audio;
stream.LocalizedDefault = _localization.GetLocalizedString("Default");
stream.LocalizedExternal = _localization.GetLocalizedString("External");
stream.LocalizedLanguage = string.IsNullOrEmpty(stream.Language)
? null
: _localization.FindLanguageInfo(stream.Language)?.DisplayName;
stream.Channels = streamInfo.Channels;
@@ -767,6 +770,9 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.LocalizedForced = _localization.GetLocalizedString("Forced");
stream.LocalizedExternal = _localization.GetLocalizedString("External");
stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
stream.LocalizedLanguage = string.IsNullOrEmpty(stream.Language)
? null
: _localization.FindLanguageInfo(stream.Language)?.DisplayName;
if (string.IsNullOrEmpty(stream.Title))
{

View File

@@ -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;

View File

@@ -41,7 +41,7 @@ namespace Jellyfin.Server.Implementations.Tests.Localization
await 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.Localization
Assert.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()
{