fix: load core translations on public sharing pages#59502
Open
bakiburakogun wants to merge 1 commit intonextcloud:masterfrom
Open
fix: load core translations on public sharing pages#59502bakiburakogun wants to merge 1 commit intonextcloud:masterfrom
bakiburakogun wants to merge 1 commit intonextcloud:masterfrom
Conversation
PublicTemplateResponse loads core JavaScript bundles (public-page-menu,
public-page-user-menu) that use runtime t('core', ...) calls for
translation. However, core translations (core/l10n/<lang>.js) were
never loaded because:
1. Util::addScript() skips addTranslations() when $application is 'core'
2. PublicTemplateResponse never explicitly called addTranslations('core')
This caused strings like 'Set public name', 'Change public name',
'You are currently not identified.' and 'User menu' to always appear
in English on public sharing pages, regardless of the configured language.
Add \OCP\Util::addTranslations('core') before the addScript calls to
ensure core translations are available for the JavaScript bundles.
Fixes: nextcloud#59501
Signed-off-by: Baki Burak Öğün <burak@burakogun.com>
susnux
requested changes
Apr 8, 2026
Contributor
susnux
left a comment
There was a problem hiding this comment.
This is not needed, translations are automatically loaded as soon as a script is loaded.
You can also see this in the browsers dev tools / network tab.
Core translations are loaded but in the wrong order, they have to be loaded directly after core-main.
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
Public sharing pages do not load core translations (
core/l10n/<lang>.js), causing strings like "Set public name", "Change public name", "You are currently not identified.", and "User menu" to always appear in English regardless of the configured language.Root Cause
In
PublicTemplateResponse.php, the constructor calls\OCP\Util::addScript('core', ...)to load JavaScript bundles (public-page-menu,public-page-user-menu). These bundles use runtimet("core", ...)calls that depend on loaded translations.However, core translations are never loaded because:
Util::addScript()inlib/public/Util.phpskipsaddTranslations()when$application === 'core'(line ~159-161)PublicTemplateResponsenever explicitly callsaddTranslations('core')As a result,
core/l10n/<lang>.jsis never included on public sharing pages, and allt("core", ...)calls fall back to English.Fix
Add
\OCP\Util::addTranslations('core')before theaddScriptcalls inPublicTemplateResponse.php.This is a one-line change that ensures core translation files are loaded on public pages, making all runtime translation calls in the public page JavaScript bundles work correctly.
Testing
'force_language' => 'tr'(or any non-English language) inconfig/config.phpAffected Pages
All public sharing pages rendered via
PublicTemplateResponse(file shares, folder shares, etc.)Fixes #59501