[PR #4679] [CLOSED] Use globalization for media stream language names #10229

Closed
opened 2026-02-07 06:16:23 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/jellyfin/jellyfin/pull/4679
Author: @bilde2910
Created: 12/5/2020
Status: Closed

Base: masterHead: full-language-name


📝 Commits (10+)

  • 7ae7608 Prioritize locally localized language names
  • 4e27ad6 Add localizations for language names
  • 39a413a Apply suggestions from code review
  • a694f57 Remove unnecessary imports
  • c781856 Merge upstream changes
  • f22dbb9 Fix duplicated assignment
  • 555c28d Add French translations of language names
  • 5cd21e0 Capitalize LocalizedString to match conventions
  • efc66a2 Fix missing capital
  • 47ce3ee Fix missing capital

📊 Changes

43 files changed (+6894 additions, -2 deletions)

View changed files

📝 Emby.Server.Implementations/Data/SqliteItemRepository.cs (+7 -0)
📝 Emby.Server.Implementations/Localization/Core/af.json (+176 -0)
📝 Emby.Server.Implementations/Localization/Core/bg-BG.json (+159 -0)
📝 Emby.Server.Implementations/Localization/Core/bn.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/ca.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/cs.json (+173 -0)
📝 Emby.Server.Implementations/Localization/Core/da.json (+138 -0)
📝 Emby.Server.Implementations/Localization/Core/de.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/en-GB.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/en-US.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/eo.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/es.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/fi.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/fr-CA.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/fr.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/gl.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/hi.json (+184 -0)
📝 Emby.Server.Implementations/Localization/Core/hr.json (+162 -0)
📝 Emby.Server.Implementations/Localization/Core/hu.json (+137 -0)
📝 Emby.Server.Implementations/Localization/Core/id.json (+173 -0)

...and 23 more files

📄 Description

This change request concerns how Jellyfin translates ISO 639-2 language codes (e.g. eng) to display names (e.g. English) when displaying media info. Jellyfin's current behavior as of 10.7.z is to use CultureInfo to resolve language names (first committed in #2773 and merged in #2788). The proposed change is to use Jellyfin's globalization infrastructure to handle this instead, and only using CultureInfo as a fallback when an unknown lanugage is encountered.

The reasons for this change request is as follows:

  • CultureInfo supplies a DisplayName that appears to be locked to English. If a user changes their language in Jellyfin, they will still see English language names in the audio and subtitle selection boxes when viewing media in Jellyfin.
  • CultureInfo does not contain mappings for all major languages. E.g. swe is mapped to Swedish, dan to Danish, but nor does not have a mapping, and falls back to displaying "Nor" in Jellyfin.
  • CultureInfo only recognizes ISO 639-2/T codes, resulting in no mapping for media that indicates an ISO 639-2/B code that differs from its T code, e.g. French (fre (B) vs fra (T)) and German (ger (B) vs deu (T)).

Using Jellyfin's globalization infrastructure allows to overcome all of these shortcomings of using CultureInfo. However, this approach also has some shortcomings:

  • If any languages are covered by .NET CultureInfo, but matching keys do not exist in localization files, mapping will fail
  • An increased number of strings to localize for translators. The current proposed set of languages to cover will add 185 new strings to Jellyfin core.

To work around these shortcomings, I propose keeping the CultureInfo lookup mechanism as a fallback. If a language exists in Jellyfin globalization files, that value will be used for rendering the full language name. If it does not exist, Jellyfin will fall back to CultureInfo. If CultureInfo also fails, fall back to displaying the language code instead, as was the default in Jellyfin up to version 10.6.z.

Regarding the number of extra strings, I am willing to help out by importing the language names from some of the most commonly used languages from the ISO 639-1 tables on Wikipedia in Weblate. Most languages should have official lists of language names somewhere that could also possibly be used to aid this process.

The goal of this change request is to improve user experience regarding language selection for media in Jellyfin, making it more reliable than it currently is in English, and improving user experience by rendering language names in the user's native language for all other Jellyfin locales (where available).

Technical changes

  • LanguageXxx keys have been added to globalization files where Xxx is the ISO 639-2/B code for the language in question. 185 such keys have been added.
  • The prefix of Language was used to avoid possible future conflicts, and to clearly group these together and indicate their purpose.
  • SqliteItemRepository.cs and ProbeResultNormalizer.cs will look up this key using the Language attribute of the MediaStream upon creation, and either set the localizedLanguage attribute of MediaStream to the localized name, or to null, depending on whether or not the language exists in globalization files.
  • MediaStream will use localizedLanguage if it is non-null, and CultureInfo if null (fallback).

Relevant issues/references


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/jellyfin/jellyfin/pull/4679 **Author:** [@bilde2910](https://github.com/bilde2910) **Created:** 12/5/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `full-language-name` --- ### 📝 Commits (10+) - [`7ae7608`](https://github.com/jellyfin/jellyfin/commit/7ae76086256b88d6548bc500b84a43cbd4734de1) Prioritize locally localized language names - [`4e27ad6`](https://github.com/jellyfin/jellyfin/commit/4e27ad6ecb6c16fda946c3a15f0cdc7d56a80107) Add localizations for language names - [`39a413a`](https://github.com/jellyfin/jellyfin/commit/39a413ab695200169ca2e39e56a6c54d5580e8e8) Apply suggestions from code review - [`a694f57`](https://github.com/jellyfin/jellyfin/commit/a694f57701878ffdcab7491ebed725f99639ebf0) Remove unnecessary imports - [`c781856`](https://github.com/jellyfin/jellyfin/commit/c78185623562d0908b8c14395f905298af48c103) Merge upstream changes - [`f22dbb9`](https://github.com/jellyfin/jellyfin/commit/f22dbb94290c6b1188f4f582af036de45083712e) Fix duplicated assignment - [`555c28d`](https://github.com/jellyfin/jellyfin/commit/555c28d4cb543fba08e035a7aa2bd90873783047) Add French translations of language names - [`5cd21e0`](https://github.com/jellyfin/jellyfin/commit/5cd21e07046f6ce9f53b6bae62c13ae216865153) Capitalize LocalizedString to match conventions - [`efc66a2`](https://github.com/jellyfin/jellyfin/commit/efc66a2611d37bc32da3181f7e0d33378f075b5d) Fix missing capital - [`47ce3ee`](https://github.com/jellyfin/jellyfin/commit/47ce3ee36e53363b458c2f2016f1203773e0028b) Fix missing capital ### 📊 Changes **43 files changed** (+6894 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `Emby.Server.Implementations/Data/SqliteItemRepository.cs` (+7 -0) 📝 `Emby.Server.Implementations/Localization/Core/af.json` (+176 -0) 📝 `Emby.Server.Implementations/Localization/Core/bg-BG.json` (+159 -0) 📝 `Emby.Server.Implementations/Localization/Core/bn.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/ca.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/cs.json` (+173 -0) 📝 `Emby.Server.Implementations/Localization/Core/da.json` (+138 -0) 📝 `Emby.Server.Implementations/Localization/Core/de.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/en-GB.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/en-US.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/eo.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/es.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/fi.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/fr-CA.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/fr.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/gl.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/hi.json` (+184 -0) 📝 `Emby.Server.Implementations/Localization/Core/hr.json` (+162 -0) 📝 `Emby.Server.Implementations/Localization/Core/hu.json` (+137 -0) 📝 `Emby.Server.Implementations/Localization/Core/id.json` (+173 -0) _...and 23 more files_ </details> ### 📄 Description This change request concerns how Jellyfin translates ISO 639-2 language codes (e.g. `eng`) to display names (e.g. `English`) when displaying media info. Jellyfin's current behavior as of 10.7.z is to use [CultureInfo](https://docs.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo.threeletterisolanguagename?view=net-5.0) to resolve language names (first committed in #2773 and merged in #2788). The proposed change is to use Jellyfin's globalization infrastructure to handle this instead, and only using CultureInfo as a fallback when an unknown lanugage is encountered. The reasons for this change request is as follows: - CultureInfo supplies a `DisplayName` that appears to be locked to English. If a user changes their language in Jellyfin, they will still see English language names in the audio and subtitle selection boxes when viewing media in Jellyfin. - CultureInfo does not contain mappings for all major languages. E.g. `swe` is mapped to `Swedish`, `dan` to Danish, but `nor` does not have a mapping, and falls back to displaying "Nor" in Jellyfin. - CultureInfo only recognizes ISO 639-2/T codes, resulting in no mapping for media that indicates an ISO 639-2/B code that differs from its T code, e.g. French (`fre` (B) vs `fra` (T)) and German (`ger` (B) vs `deu` (T)). Using Jellyfin's globalization infrastructure allows to overcome all of these shortcomings of using CultureInfo. However, this approach also has some shortcomings: - If any languages are covered by .NET CultureInfo, but matching keys do not exist in localization files, mapping will fail - An increased number of strings to localize for translators. The current proposed set of languages to cover will add 185 new strings to Jellyfin core. To work around these shortcomings, I propose keeping the CultureInfo lookup mechanism as a fallback. If a language exists in Jellyfin globalization files, that value will be used for rendering the full language name. If it does not exist, Jellyfin will fall back to CultureInfo. If CultureInfo also fails, fall back to displaying the language code instead, as was the default in Jellyfin up to version 10.6.z. Regarding the number of extra strings, I am willing to help out by importing the language names from some of the most commonly used languages from the ISO 639-1 tables on Wikipedia in Weblate. Most languages should have official lists of language names somewhere that could also possibly be used to aid this process. The goal of this change request is to improve user experience regarding language selection for media in Jellyfin, making it more reliable than it currently is in English, and improving user experience by rendering language names in the user's native language for all other Jellyfin locales (where available). ## Technical changes - `LanguageXxx` keys have been added to globalization files where `Xxx` is the ISO 639-2/B code for the language in question. 185 such keys have been added. - The prefix of `Language` was used to avoid possible future conflicts, and to clearly group these together and indicate their purpose. - `SqliteItemRepository.cs` and `ProbeResultNormalizer.cs` will look up this key using the `Language` attribute of the `MediaStream` upon creation, and either set the `localizedLanguage` attribute of MediaStream to the localized name, or to null, depending on whether or not the language exists in globalization files. - `MediaStream` will use `localizedLanguage` if it is non-null, and CultureInfo if null (fallback). ## Relevant issues/references - CultureInfo commited in #2773 - Merged in #2788 - Implements FR [534](https://features.jellyfin.org/posts/534/subtitle-abbreviation) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-07 06:16:23 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/jellyfin#10229