Problem/Motivation
Tour strings are not translatable, should be "label" in schema. Furthermore we should check if anything else is translatable correctly.
As this is a major issue for multilingual projects with Tours, I'll update the priority accordingly. They'll always see the English text and have no way to fix it.
Steps to reproduce
Try translating some configuration like
- Tour available text
- Tour not available text
Proposed resolution
- Correct from type "text" to "label" in schema
- Add a config_translation .yml
- Check translatability of the Tour tooltips and entities in general - might also have other issues
Possible technical solutions from #7:
1) Find a way to exclude "Drupal." variable from minification in Vite. I already looked for that in another issue, but couldn't find it. Hopefully there is a way!
2) Load the library "the Drupal way" as discussed here #3548238: Broken when using JS aggregation: DOMException: IntersectionObserver constructor: rootMargin must be specified in pixels or percent.
3) Add a second "regular" JS that is not built by vite and replaces the translation strings (if that is technically posible)
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | screenshot-2025-11-21 14_37_59.png | 5.65 KB | grevil |
| #18 | screenshot-2025-11-21 14_36_43.png | 4.67 KB | grevil |
| #8 | dirty-fix-for-german-and-english.patch | 138.46 KB | grevil |
Issue fork tour-3552263
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
anybodyStartet some basic work, but should be checked if everything else is fine and working... plus the config_translation yml
Comment #5
grevil commentedI added the config_translation.yml. Everything looks ok, but I can not seem to get the Next / Previous Buttons translated, no matter what. I already translated "Next" and "Previous" in the User Interface translation, cleared all caches and ran cron several times to check, if there are new / multiple "Next" and "Previous" elements on the translation page, but no.
I also rebuilt the tour.js and added console.logs for the `tourStepConfig` to check if "Drupal.tour.nextButton" and "Drupal.tour.previousButton" works as expected, but everything looks fine. Seems like Drupal.t doesn't work in that context for some reason.
We should investigate this further.
Comment #6
grevil commentedI think I found the problem. Since the minification and build process is done through vite, there is no actual "Drupal.t()" in the processed tour.js anymore and the Drupal t regex won't match, which results in the string not being translated.
I tried turning off the minifaction in the vite config, but this results in further console errors AND the function becomes "Drupal2.t()" which could also still be a problem.
Unsure how to continue here, since we established, that we don't want to use the "normal" Drupal approach for the js library here: https://www.drupal.org/project/tour/issues/3548238#comment-16282931.
@smustgrave, what do you think? Any idea, besides refactoring the JS library to conform to Drupal standards?
Comment #7
anybodyOh no, that's indeed a bigger problem, then!
I see three potential fixes here:
1) Find a way to exclude "Drupal." variable from minification in Vite. I already looked for that in another issue, but couldn't find it. Hopefully there is a way!
2) Load the library "the Drupal way" as discussed here #3548238: Broken when using JS aggregation: DOMException: IntersectionObserver constructor: rootMargin must be specified in pixels or percent.
3) Add a second "regular" JS that is not built by vite and replaces the translation strings (if that is technically posible)
As this is a major issue for multilingual projects with Tours, I'll update the priority accordingly. They'll always see the English text and have no way to fix it.
Comment #8
grevil commentedHere is a filthy fix when using german and english.
Comment #9
anybodyComment #10
anybodyComment #11
anybody@grevil: Could you please comment the three technical solutions one by one from your experience here?
Comment #12
grevil commentedSure thing.
1) Could be a good quick fix, but I'd go for 2) in the long run (if possible). 3) is probably not possible, since this "regular" js needs to modify the nextButton / prevButton via the Drupal.t() regex, BEFORE building and since we are not building dynamically, this will never happen.
I'd vote for 2). No idea, if we have any other options apart from the three.
Comment #13
anybody(3) might be the easiest fix, but someone needs to find out if the button text can be replaced at runtime. At build time that can't be done, as you correctly wrote in #12.
Comment #14
smustgrave commentedIf the problem is this I’d aggregated we can revisit breaking the js up but I don’t want to do major rewrites to tour.js
Comment #15
smustgrave commentedWill admit I tried breaking apart the files but just ended up breaking everything, couldn't get around shepherd is now a .mjs when in core it was an older version that was just js.
Comment #16
smustgrave commentedSee #3557783: Attempt to break part tour.js
Comment #17
smustgrave commentedComment #18
grevil commentedAlright, this works great together with #3557783: Attempt to break part tour.js!
Just one minor adjustment, we need to use "tour.tour_settings" as the base route, otherwise the translation tab won't be created. I manually adjusted the weight, so it looks how it looked before:
EDIT: Sorry wrong screenshot.
That's it. RTBC!
Comment #19
grevil commentedCorrect screenshot:

Comment #20
smustgrave commented