Skip to content

fix(l10n): import t where scripts call it - #3341

Merged
enjeck merged 2 commits into
mainfrom
fix/noid/import-translate-helpers
Nov 29, 2026
Merged

enjeck merged 2 commits into
mainfrom
fix/noid/import-translate-helpers

Conversation

@rubenvdlinde

Copy link
Copy Markdown
Contributor

Six scripts call t() without importing it and rely on the global that Nextcloud sets on the page: displayError.js, both Pinia stores (store.js, data.js), and the shareAPI, copyToClipboard and searchUserGroup mixins. On a full page that works, but outside it, as in the Cypress component tests, the global is missing. An error toast then throws "t is not defined" instead of showing.

That is what makes SmartPickerPreview.cy.js fail now and then on unrelated PRs: when a preview request fails, displayError() throws inside an unhandled promise and Cypress fails the test. Each file now imports translate as t from @nextcloud/l10n, like the other 58 modules do.

How it was tested

New cypress/component/displayError.cy.js: builds the not-found and load-error messages and reports a failed request for status 400, 401, 403, 404 and 500, with no global t. Without the change both tests fail with "t is not defined"; with it they pass. The full component suite passes (65 tests). eslint is clean on the changed files.

🖼️ Screenshots

None, no visible change.

🏁 Checklist

  • ⛑️ Tests (unit and/or integration) are included or not needed
  • 🔙 Backport requests are created or not needed: /backport to stableX.X
  • 📅 Milestone is set
  • 🌸 PR title is meaningful (if it should be in the changelog: is it meaningful to users?)

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI

These modules relied on the global t() that Nextcloud sets on the page. Outside a
full page, as in the component tests, that global is missing, so an error toast
threw "t is not defined" instead of showing; this made SmartPickerPreview fail
whenever a preview request failed.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>

@enjeck enjeck left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

a question:

Comment thread cypress/component/displayError.cy.js Resolved
@blizzz blizzz added bug Something isn't working 2. developing Work in progress labels Nov 24, 2026

@AndyScherzinger AndyScherzinger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Two more scripts call t() without importing it:

  • src/shared/mixins/relativeDate.js:13 calls t('core', 'seconds ago'). ActivityEntry.vue, ShareList.vue, ShareInfoPopover.vue, ColumnInfoPopover.vue and EditColumn.vue use this mixin. A component test that renders one of them with a timestamp less than 45 seconds old therefore hits the same "t is not defined" error.
  • src/file-actions.js:20 calls t('tables', 'Import into Tables'). It runs in the Files app, where the global t exists, so nothing breaks today. It is the only entry point still relying on the global.

Neither file is part of the diff, so I'm commenting here rather than inline.

Validated: code check only. I searched every .js and .ts file under src/ at 1e61cb2d for t() and n() calls without an @nextcloud/l10n import. The remaining n() calls are in templates, which get it from globalProperties in main.js.

The relative date mixin threw "t is not defined" outside a full page for a time
less than 45 seconds ago, and the Files action was the last entry point relying on
the global.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ruben van der Linde <ruben@conduction.nl>
@enjeck
enjeck merged commit fec9be6 into main Nov 29, 2026
60 of 62 checks passed
@enjeck
enjeck deleted the fix/noid/import-translate-helpers branch November 29, 2026 17:33
@rubenvdlinde

Copy link
Copy Markdown
Contributor Author

/backport to stable2

@backportbot backportbot Bot added the backport-request Pending backport by the backport-bot label Nov 30, 2026
@backportbot backportbot Bot removed the backport-request Pending backport by the backport-bot label Nov 30, 2026
@rubenvdlinde

Copy link
Copy Markdown
Contributor Author

Thanks for the search. Both are fixed in "fix(l10n): import t in the relative date mixin and the file action": relativeDate.js and file-actions.js now import t like the rest. A new component test renders the mixin with a time a few seconds ago and fails with "t is not defined" without the import. With these, no script under src/ calls t() without importing it.

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

Labels

2. developing Work in progress AI assisted bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants