Skip to content

fix: load core translations on public sharing pages#59502

Open
bakiburakogun wants to merge 1 commit intonextcloud:masterfrom
bakiburakogun:fix/public-page-core-translations
Open

fix: load core translations on public sharing pages#59502
bakiburakogun wants to merge 1 commit intonextcloud:masterfrom
bakiburakogun:fix/public-page-core-translations

Conversation

@bakiburakogun
Copy link
Copy Markdown

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 runtime t("core", ...) calls that depend on loaded translations.

However, core translations are never loaded because:

  1. Util::addScript() in lib/public/Util.php skips addTranslations() when $application === 'core' (line ~159-161)
  2. PublicTemplateResponse never explicitly calls addTranslations('core')

As a result, core/l10n/<lang>.js is never included on public sharing pages, and all t("core", ...) calls fall back to English.

Fix

Add \OCP\Util::addTranslations('core') before the addScript calls in PublicTemplateResponse.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

  1. Set 'force_language' => 'tr' (or any non-English language) in config/config.php
  2. Create a public share link for any file/folder
  3. Open the link in an incognito window
  4. Before fix: "Set public name", "You are currently not identified." appear in English
  5. After fix: These strings appear in the configured language

Affected Pages

All public sharing pages rendered via PublicTemplateResponse (file shares, folder shares, etc.)

Fixes #59501

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>
@bakiburakogun bakiburakogun requested a review from a team as a code owner April 8, 2026 10:51
@bakiburakogun bakiburakogun requested review from CarlSchwan, come-nc, leftybournes and salmart-dev and removed request for a team April 8, 2026 10:51
Copy link
Copy Markdown
Contributor

@susnux susnux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Core translations not loaded on public sharing pages (PublicTemplateResponse)

2 participants