Truncate ISO-639-2 language display names at first delimiter
Prevents raw ISO-639-2 values (e.g. "Greek, Modern (1453-)" from cluttering the audio and subtitle display names by truncating them at the first comma or semicolon ("Greek"). Applies to MediaStreamRepository and ProbeResultNormalizer.
This commit is contained in:
@@ -173,7 +173,10 @@ public class MediaStreamRepository : IMediaStreamRepository
|
||||
if (!string.IsNullOrEmpty(dto.Language))
|
||||
{
|
||||
var culture = _localization.FindLanguageInfo(dto.Language);
|
||||
dto.LocalizedLanguage = culture?.DisplayName;
|
||||
// Truncate at the first delimiter to avoid cluttered display names
|
||||
dto.LocalizedLanguage = culture?.DisplayName is { } name
|
||||
? name.Split(';', ',')[0].Trim()
|
||||
: null;
|
||||
}
|
||||
|
||||
if (dto.Type is MediaStreamType.Audio)
|
||||
|
||||
@@ -732,7 +732,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
stream.LocalizedOriginal = _localization.GetLocalizedString("Original");
|
||||
stream.LocalizedLanguage = string.IsNullOrEmpty(stream.Language)
|
||||
? null
|
||||
: _localization.FindLanguageInfo(stream.Language)?.DisplayName;
|
||||
: _localization.FindLanguageInfo(stream.Language)?.DisplayName is { } name
|
||||
? name.Split(';', ',')[0].Trim()
|
||||
: null;
|
||||
|
||||
stream.Channels = streamInfo.Channels;
|
||||
|
||||
@@ -773,7 +775,9 @@ namespace MediaBrowser.MediaEncoding.Probing
|
||||
stream.LocalizedHearingImpaired = _localization.GetLocalizedString("HearingImpaired");
|
||||
stream.LocalizedLanguage = string.IsNullOrEmpty(stream.Language)
|
||||
? null
|
||||
: _localization.FindLanguageInfo(stream.Language)?.DisplayName;
|
||||
: _localization.FindLanguageInfo(stream.Language)?.DisplayName is { } name
|
||||
? name.Split(';', ',')[0].Trim()
|
||||
: null;
|
||||
|
||||
if (string.IsNullOrEmpty(stream.Title))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user