diff options
| author | 854562 <44002186+854562@users.noreply.github.com> | 2026-07-20 22:00:10 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-07-20 22:00:10 +0200 |
| commit | 2cd2f36fe4912cb465cf5e78a055463f8a5c44a9 (patch) | |
| tree | 66aa4121c8da9fa4253223428fc3810189c88e7f /Emby.Server.Implementations/Localization/LocalizationManager.cs | |
| parent | c632417dda8e3f9a2472ad0bdd43c69d38d95f62 (diff) | |
Extract truncation logic to helper and add tests
Diffstat (limited to 'Emby.Server.Implementations/Localization/LocalizationManager.cs')
| -rw-r--r-- | Emby.Server.Implementations/Localization/LocalizationManager.cs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.cs index 843e35afcc..068dde639e 100644 --- a/Emby.Server.Implementations/Localization/LocalizationManager.cs +++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs @@ -262,6 +262,24 @@ namespace Emby.Server.Implementations.Localization } /// <inheritdoc /> + public string? GetLanguageDisplayName(string language) + { + if (string.IsNullOrEmpty(language)) + { + return null; + } + + var displayName = FindLanguageInfo(language)?.DisplayName; + if (displayName is null) + { + return null; + } + + // Truncate at the first delimiter to avoid cluttered display names + return displayName.Split([';', ','], StringSplitOptions.None)[0].Trim(); + } + + /// <inheritdoc /> public IReadOnlyList<CountryInfo> GetCountries() { using var stream = _assembly.GetManifestResourceStream(CountriesPath) ?? throw new InvalidOperationException($"Invalid resource path: '{CountriesPath}'"); |
