Issue Feature Closed

#108941Adjusting JavaScript Language Label Handling in TYPO3

Tobias Wojtylak 02/11/26, 11:54 updated 03/31/26, 08:11

Description

Problem

The JavaScript function lll (defined in https://github.com/TYPO3/typo3/blob/main/Build/Sources/TypeScript/core/lit-helper.ts#L43) searches for the requested label in the current window and the top window. Labels in the top frame are restricted to the backend scope.

If you e.g. create a modal like this:

const content = html`
    <typo3-component-with-lll-calls />
`;
Modal.advanced({
    title: lll('Hello World'),
});

…and your component <typo3-component-with-lll-calls> calls `lll` for labels that exist in the current frame but not in the top frame, these labels will not be resolved.</typo3-component-with-lll-calls>

Current Workarounds

Currently, developers manually add TYPO3.lang as a custom property on modal child elements via Modal callbacks , e.g.:

form.TYPO3lang = TYPO3.lang;

and do not use the generic `lll` function, which has some drawbacks e.g. placeholders are not replaced in these cases.

Reference: https://github.com/TYPO3/typo3/blob/main/Build/Sources/TypeScript/workspaces/workspaces.ts#L57

Proposed Solutions

1. Search Child Frames as Fallback (Quick Win?)

If a language key is not found in the current or top frame, we could search the child frames for the label:

else if (window.self === window.top) {
    // fallback: search child frames for translation key
    for (let i = 0; i < window.frames.length; i++) {
        try {
            if (typeof window.frames[i]?.TYPO3?.lang[key] === 'string') {
                languagePool = window.frames[i].TYPO3.lang;
                break;
            }
        } catch {
            // cross-origin frame, skip
        }
    }
}

✅ Pros

  1. Simple and fast to implement

❌ Cons

  1. Language strings must still exist in the “main” frame (e.g., passed via `PageRenderer::addInlineLanguageDomain`).

2. Load Translation Keys Dynamically via AJAX

  1. If a key (possibly including a translation domain, e.g., form.messages:validation.error.1221565130 ( TBD : If it is possible to determine whether the key contains a translation domain? Yes: everything before `:`) is missing from TYPO3.lang, we load the translation file dynamically via an AJAX request.
  2. The request would pass the translation domain (e.g., form.messages).
  3. A TYPO3 backend controller would use LanguageService::getLabelsFromResource to return the labels.
  4. These labels could then be stored in a JavaScript object, e.g., `TYPO3.langByDomain` (TBD: key), and accessed via lll.

✅ Pros

  1. Language strings do not need to be predefined in frames; they are loaded dynamically when needed.

❌ Cons

  1. A new translation function may be required to support passing a translation domain (the current lll signature is (key: string, …args: any[]) and cannot accept additional parameters).
  2. Implementation is more complex.

Reviews 9

History 914

  1. Benjamin Franzke commented <span data-processor="relativetime" data-value="2026-02-12T08:21:15+00:00" > 02/12/26, 08:21 </span>

    Third solution:

    Provide virtual JavaScipt module(s) for labels

    Advantages over an ajax endpoint:

    • Labels can be defined as a module dependency, which means that components can use the labels synchronously inside the module and can render content directly, instead of making everything async. (We have the same problems with the Icons API, btw)
    • Labels do not require a store (the module loader is the store)
    • No global dependency to a ajax endpoint (that needs to be read from TYPO3.settings global)
    import labels from '~labels/core.bookmarks';
    
    // …
    
    render() {
      return html`<p>{labels.get('my.label')}</p>`
    }

    Here is a Demo:
    92810: [WIP][FEATURE] Provide language label domains as virtual javascript modules | https://review.typo3.org/c/Packages/TYPO3.CMS/+/92810

  2. Benjamin Franzke commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-02-16T13:55:08+00:00" > 02/16/26, 13:55 </span>

    Applied in changeset commit:455b3654941169be492274dac2b29a2673b754a5.

  3. Benjamin Franzke changed tracker Task Feature subject RFC: Adjusting JavaScript Language Label Handling in TYPO3 Adjusting JavaScript Language Label Handling in TYPO3 parent task #109064 TYPO3 Version 14 <span data-processor="relativetime" data-value="2026-02-23T08:00:04+00:00" > 02/23/26, 08:00 </span>