Problem

The editor JavaScript and stylesheets lost a few things on the way from Drupal 7:

  • Hovering a placeholder highlighted every placeholder with the same name in the row on Drupal 7. On 3.0.x the handler binds to the placeholders at load, before the markup creates them, so it never works.
  • Drupal 7 marked :name placeholders too and left the API of JSON:API alone. 3.0.x marks only !, @ and % placeholders.
  • Drupal 7 also listened to the text event because keyup does not fire reliably while composing text with an input method (Japanese, Chinese, Korean). 3.0.x only listens to keyup, so the diff and the markup lag behind for those translators.
  • The Drupal 7 word diff treated Chinese, Japanese and Korean characters as words of their own. Without those ranges one changed character shows the whole line as replaced.
  • The Drupal 7 translation table had the sticky header every Drupal 7 table had. 3.0.x tables are not sticky by default.
  • The Drupal 7 right-to-left rules for the overview tables, the progress bars and the filter form were not ported, two rules of the editor ones are missing.
  • The 3.0.x editor stylesheet sets a font on the page body, which is the theme's business.
  • The base module attaches its table script on every page without declaring its core/once dependency, a JavaScript error on any page where nothing else loads once.

Proposed resolution

  • Bind the placeholder hover handlers on the document, like the Drupal 7 live binding.
  • The placeholder pattern takes :name and skips JSON:API (with a callback rather than the Drupal 7 lookbehind, which the legacy ESLint parser refuses).
  • The textarea handler runs on the input event too, the standard event input methods fire.
  • The Drupal 7 character ranges go back into the word diff tokenizer.
  • The translation table is sticky, the stylesheet already styled that.
  • The Drupal 7 right-to-left rules as [dir="rtl"] rules in the split stylesheets, and the two editor rules.
  • The body font rule goes. The table script library declares core/once.

Tests

Drupal 7 has no JavaScript tests, its editor.js is the specification. The functional test base setup moves into a trait, shared with a new JavaScript test base, so both kinds of tests get the same languages, users and project helpers. L10nEditorTest runs in a browser (Selenium) and checks the placeholder markup including :name and the excluded JSON:API, the hover highlight, the input event, the tokenizer on Japanese text, the sticky table and the untouched body font. The JavaScript error check of the browser test found the missing once dependency.

LLM disclosure

LLM was used to find, diagnose explain and fix this issue. With human review.

Comments

gábor hojtsy created an issue. See original summary.

  • ace278e2 committed on 3.0.x
    fix #3621730: Translation editor: placeholder highlight never binds, :...
gábor hojtsy’s picture

Status: Active » 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.