The Free Software Media System - Server Backend & API
Address review comments
Shadowghost7a5181c3fd3a
diff --git a/Emby.Server.Implementations/Localization/Core/en-US.json b/Emby.Server.Implementations/Localization/Core/en-US.jsonindex ff674bd0d0..856941c61a 100644--- a/Emby.Server.Implementations/Localization/Core/en-US.json+++ b/Emby.Server.Implementations/Localization/Core/en-US.json@@ -93,8 +93,8 @@"TaskUpdatePluginsDescription": "Downloads and installs updates for plugins that are configured to update automatically.","TaskCleanTranscode": "Clean Transcode Directory","TaskCleanTranscodeDescription": "Deletes transcode files more than one day old.",- "TasksRefreshChannels": "Refresh Channels",- "TasksRefreshChannelsDescription": "Refreshes internet channel information.",+ "TaskRefreshChannels": "Refresh Channels",+ "TaskRefreshChannelsDescription": "Refreshes internet channel information.","TaskDownloadMissingLyrics": "Download missing lyrics","TaskDownloadMissingLyricsDescription": "Downloads lyrics for songs","TaskDownloadMissingSubtitles": "Download missing subtitles",diff --git a/Emby.Server.Implementations/Localization/LocalizationManager.cs b/Emby.Server.Implementations/Localization/LocalizationManager.csindex 94aa933c92..0b0b300d30 100644--- a/Emby.Server.Implementations/Localization/LocalizationManager.cs+++ b/Emby.Server.Implementations/Localization/LocalizationManager.cs@@ -77,22 +77,36 @@ namespace Emby.Server.Implementations.Localizationvar cultures = new List<CultureInfo>();foreach (var option in _localizationOptions){- // Resource files use underscores for some variants (e.g. es_419);- // CultureInfo only accepts hyphenated BCP-47 codes.- var code = option.Value.Replace('_', '-');- try- {- cultures.Add(CultureInfo.GetCultureInfo(code));- }- catch (CultureNotFoundException)+ // Skip novelty codes (e.g. "pr" Pirate, "jbo" Lojban) that .NET cannot resolve.+ if (TryGetCultureInfo(option.Value, out var cultureInfo)){- // Skip novelty codes (e.g. "pr" Pirate, "jbo" Lojban) that .NET cannot resolve.+ cultures.Add(cultureInfo);}}return cultures;}+ /// <summary>+ /// Resolves a Jellyfin resource culture code (which may use underscores, e.g. <c>es_419</c>)+ /// to a <see cref="CultureInfo"/>. Returns <see langword="false"/> for codes .NET cannot resolve.+ /// </summary>+ private static bool TryGetCultureInfo(string cultureCode, [NotNullWhen(true)] out CultureInfo? cultureInfo)+ {+ try+ {+ // Resource files use underscores for some variants (e.g. es_419);+ // CultureInfo only accepts hyphenated BCP-47 codes.+ cultureInfo = CultureInfo.GetCultureInfo(cultureCode.Replace('_', '-'));+ return true;+ }+ catch (CultureNotFoundException)+ {+ cultureInfo = null;+ return false;+ }+ }+private static void OnConfigurationUpdated(object? sender, EventArgs e){if (sender is IServerConfigurationManager configManager)@@ -614,20 +628,10 @@ namespace Emby.Server.Implementations.Localizationprivate static string GetDisplayName(string cultureCode){- // Resource files use underscores for codes that .NET's CultureInfo doesn't accept directly (e.g. es_419).- var lookup = cultureCode.Contains('_', StringComparison.Ordinal)- ? cultureCode.Replace('_', '-')+ // Custom/novelty codes like "pr" (Pirate) — fall back to code itself+ return TryGetCultureInfo(cultureCode, out var cultureInfo)+ ? cultureInfo.NativeName: cultureCode;-- try- {- return CultureInfo.GetCultureInfo(lookup).NativeName;- }- catch (CultureNotFoundException)- {- // Custom/novelty codes like "pr" (Pirate) — fall back to code itself- return cultureCode;- }}/// <inheritdoc />diff --git a/src/Jellyfin.LiveTv/Channels/RefreshChannelsScheduledTask.cs b/src/Jellyfin.LiveTv/Channels/RefreshChannelsScheduledTask.csindex 71e46764ad..bb4238a2ac 100644--- a/src/Jellyfin.LiveTv/Channels/RefreshChannelsScheduledTask.cs+++ b/src/Jellyfin.LiveTv/Channels/RefreshChannelsScheduledTask.cs@@ -40,10 +40,10 @@ namespace Jellyfin.LiveTv.Channels}/// <inheritdoc />- public string Name => _localization.GetLocalizedString("TasksRefreshChannels");+ public string Name => _localization.GetLocalizedString("TaskRefreshChannels");/// <inheritdoc />- public string Description => _localization.GetLocalizedString("TasksRefreshChannelsDescription");+ public string Description => _localization.GetLocalizedString("TaskRefreshChannelsDescription");/// <inheritdoc />public string Category => _localization.GetLocalizedString("TasksChannelsCategory");