fix: use static language list instead of l10nFactory for translation providers#358
Open
bakiburakogun wants to merge 1 commit intonextcloud:mainfrom
Open
Conversation
…providers When force_language is set in config.php, l10nFactory->getLanguages() returns only the forced language, causing translation providers to offer an empty or single-language list. AI translation services can translate any language regardless of installed Nextcloud UI languages. Introduce a shared LanguageList helper class with common ISO 639 languages. Both OldTranslationProvider and TranslateProvider now use this static list instead of depending on l10nFactory for determining available translation languages. Fixes nextcloud#357
lukasdotcom
reviewed
Apr 10, 2026
Member
lukasdotcom
left a comment
There was a problem hiding this comment.
Thanks. It looks good I have a little bit of feedback, and to fix the DCO check you need to sign your commits. The instructions for that are at https://github.com/nextcloud/integration_openai/pull/358/checks?check_run_id=70509628723
| * @return array<array{code: string, name: string}> | ||
| */ | ||
| public static function getLanguages(): array { | ||
| return [ |
Member
There was a problem hiding this comment.
The languages should be internationalized. I would just use the endonyms (https://en.wikipedia.org/wiki/Endonym_and_exonym) for them. Also could you merge it with the list in https://github.com/nextcloud/integration_openai/blob/main/lib/AppInfo/Application.php#L83 and use your getLanguages for where that constant is being used so there is only one list.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
force_languageis set inconfig.php,l10nFactory->getLanguages()returns only the forced language (or a very limited set), causing bothOldTranslationProviderandTranslateProviderto offer an empty or single-language list to consumers like Spreed's message translation dialog.AI translation services (OpenAI, LocalAI, etc.) can translate between any languages regardless of which Nextcloud UI languages are installed. The available translation language list should therefore not depend on
l10nFactory.Changes
lib/Translation/LanguageList.php: A shared static helper class providing ~80 common ISO 639 languages with English names. ExposesgetLanguages()(array of['code' => ..., 'name' => ...]) andgetLanguagesByCode()(code => namemap).OldTranslationProvider:getAvailableLanguages()andgetCoreLanguagesByCode()now useLanguageListinstead ofl10nFactory->getLanguages().TranslateProvider:getInputShapeEnumValues()andgetCoreLanguagesByCode()now useLanguageListinstead ofl10nFactory->getLanguages().How to reproduce
'force_language' => 'tr'(or any single language) inconfig.phpWith this fix, all ~80 common languages are always available.
Fixes #357