Unverified Commit 853a645a authored by David López's avatar David López Committed by GitHub
Browse files

Merge pull request #18005 from dannon/fix-localization-spacing

[24.0] Preserve surrounding whitespace when localizing complex nodes
parents 6f3e5152 3e89eeb4
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -12,11 +12,14 @@ function localizeDirective(l) {
        // TODO consider using a different hook if we need dynamic updates in content translation
        bind(el, binding, vnode) {
            el.childNodes.forEach((node) => {
                // trim for lookup, but put back whitespace after
                const leadingSpace = node.textContent.match(/^\s*/)[0];
                const trailingSpace = node.textContent.match(/\s*$/)[0];
                const standardizedContent = node.textContent
                    .replace(newlineMatch, " ")
                    .replace(doublespaces, " ")
                    .trim();
                node.textContent = l(standardizedContent);
                node.textContent = leadingSpace + l(standardizedContent) + trailingSpace;
            });
        },
    };