Repository navigation
fix(l10n): import t where scripts call it - #3341
Conversation
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>
AndyScherzinger
left a comment
There was a problem hiding this comment.
Two more scripts call t() without importing it:
src/shared/mixins/relativeDate.js:13callst('core', 'seconds ago').ActivityEntry.vue,ShareList.vue,ShareInfoPopover.vue,ColumnInfoPopover.vueandEditColumn.vueuse 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:20callst('tables', 'Import into Tables'). It runs in the Files app, where the globaltexists, 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>
|
/backport to stable2 |
|
Thanks for the search. Both are fixed in "fix(l10n): import t in the relative date mixin and the file action": |
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 theshareAPI,copyToClipboardandsearchUserGroupmixins. 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.jsfail 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 importstranslate as tfrom@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 globalt. Without the change both tests fail with "t is not defined"; with it they pass. The full component suite passes (65 tests).eslintis clean on the changed files.🖼️ Screenshots
None, no visible change.
🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)