Skip to content

Comments

Script: Translation Check#4861

Draft
crhallberg wants to merge 5 commits intovufind-org:devfrom
crhallberg:script-translate-check
Draft

Script: Translation Check#4861
crhallberg wants to merge 5 commits intovufind-org:devfrom
crhallberg:script-translate-check

Conversation

@crhallberg
Copy link
Contributor

@crhallberg crhallberg commented Nov 14, 2025

A script to find missing and extra PHP-to-JS translation strings.

TODO

  • Fix the problems revealed by the script
  • Wire this into continuous integration

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks for sharing this, @crhallberg! The PR had some of the channels code unexpectedly included, but I've merged with dev and resolved conflicts and now we're just seeing the one new file.

I tried to run this, but it didn't work for me:

dkatz@dkatz-VirtualBox:/usr/local/vufind$ node themes/bootstrap5/tools/jsTranslationsCheck.mjs 
Error globbing synchronously: TypeError: fs.globSync is not a function or its return value is not iterable
    at file:///usr/local/vufind/themes/bootstrap5/tools/jsTranslationsCheck.mjs:61:24
    at ModuleJob.run (node:internal/modules/esm/module_job:193:25)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:530:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12)

What am I doing wrong?

@demiankatz demiankatz added the tooling pull requests that change project tooling label Nov 17, 2025
@crhallberg crhallberg closed this Nov 17, 2025
@crhallberg crhallberg force-pushed the script-translate-check branch from a9ba2cc to 703daf9 Compare November 17, 2025 21:04
@crhallberg crhallberg reopened this Nov 17, 2025
@crhallberg
Copy link
Contributor Author

I was seeing a mess of commits, sorry for the force push.

@crhallberg
Copy link
Contributor Author

crhallberg commented Nov 17, 2025

dkatz@dkatz-VirtualBox:/usr/local/vufind$ node themes/bootstrap5/tools/jsTranslationsCheck.mjs 
Error globbing synchronously: TypeError: fs.globSync is not a function or its return value is not iterable

What version of Node are you using? It looks like this was added in Node v22.

@demiankatz
Copy link
Member

@crhallberg, I'm running Ubuntu 24, which has node v18 installed. That version is out of active support, but we should probably avoid using features that don't work in node 20 as a baseline.

@crhallberg
Copy link
Contributor Author

I see, Node v22 is the new LTS version but v20 is still LTS.

Copy link
Member

@demiankatz demiankatz left a comment

Choose a reason for hiding this comment

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

Thanks, @crhallberg. I've at least moved on to a new set of errors now...

First, I got this:

Error globbing synchronously: Error: EACCES: permission denied, scandir 'data/cache/browscap/browscap-00'
    at read (node:fs:1399:35)
    at readdirSyncRecursive (node:fs:1437:5)
    at Object.readdirSync (node:fs:1504:12)
    at file:///usr/local/vufind/themes/bootstrap5/tools/jsTranslationsCheck.mjs:55:25
    at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: 'data/cache/browscap/browscap-00'
}

There was some Apache-owned junk in my cache folders that my regular user did not have permission to read. Can we make it more tolerant of unreadable files, or have it explicitly ignore cache dirs? In any case, I cleared the cache, and then I got this:

Error globbing synchronously: Error: ENOENT: no such file or directory, open './js/map_selection_leaflet.js'
    at Object.readFileSync (node:fs:449:20)
    at file:///usr/local/vufind/themes/bootstrap5/tools/jsTranslationsCheck.mjs:73:26
    at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: './js/map_selection_leaflet.js'
}

Looks like the script expects you to be in $VUFIND_HOME/themes/bootstrap5, and I was running it from $VUFIND_HOME. Can we make it more directory-agnostic?

In any case, I then switched to the desired theme directory, and ended up with this:

Error globbing synchronously: TypeError: jsStrings.union is not a function
    at file:///usr/local/vufind/themes/bootstrap5/tools/jsTranslationsCheck.mjs:74:26
    at ModuleJob.run (node:internal/modules/esm/module_job:325:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:606:24)
    at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:117:5)

...and I'm not sure why that is failing. I'm running node v20.19.5 if that makes any difference.

@demiankatz
Copy link
Member

Thanks, @crhallberg, this is working for me now! Looks like there are some issues here that need to be fixed, in fact! Should we wire this up into continuous integration so the build fails if missing or extra strings are found?

(I guess the first step is to see if we can fix all of the problems and that there are no false positives left behind after we do).

Would you like me to help with the cleanup, or do you want to do it?

@demiankatz demiankatz added this to the 11.1 milestone Dec 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tooling pull requests that change project tooling

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants