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

  1. Correct from type "text" to "label" in schema
  2. Add a config_translation .yml
  3. 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

Issue fork tour-3552263

Command icon 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

anybody created an issue. See original summary.

anybody’s picture

Status: Active » Needs work

Startet some basic work, but should be checked if everything else is fine and working... plus the config_translation yml

grevil made their first commit to this issue’s fork.

grevil’s picture

I 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.

grevil’s picture

I 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?

anybody’s picture

Priority: Normal » Major

Oh 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.

grevil’s picture

StatusFileSize
new138.46 KB

Here is a filthy fix when using german and english.

anybody’s picture

Issue summary: View changes
anybody’s picture

Issue summary: View changes
anybody’s picture

@grevil: Could you please comment the three technical solutions one by one from your experience here?

grevil’s picture

Sure 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.

anybody’s picture

(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.

smustgrave’s picture

If 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

smustgrave’s picture

Will 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.

smustgrave’s picture

smustgrave’s picture

Status: Needs work » Postponed
Related issues: +#3557783: Attempt to break part tour.js
grevil’s picture

Status: Postponed » Reviewed & tested by the community
StatusFileSize
new4.67 KB

Alright, 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!

grevil’s picture

StatusFileSize
new5.65 KB

Correct screenshot:
screenshot2

smustgrave’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.