Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML overlays #11

Open
tobyzerner opened this issue Feb 23, 2022 · 0 comments
Open

HTML overlays #11

tobyzerner opened this issue Feb 23, 2022 · 0 comments

Comments

@tobyzerner
Copy link

Would be great to include a utility to overlay translations onto DOM, as per https://github.com/projectfluent/fluent.js/wiki/DOM-Overlays.

Obviously in PHP we work with HTML strings rather than the DOM itself, so the API would be slightly different.

In my abandoned fluent-php library, I had a 1:1 port of this functionality working with this API:

Overlay::translateHtml(
    '<p><img data-l10n-name="world" src="world.png"></p>',
    [
        'value' => 'Hello, <img data-l10n-name="world" alt="world">!', 
        'attributes' => ['title' => 'Hello']
    ]
);
// → <p title="Hello">Hello, <img data-l10n-name="world" alt="world" src="world.png">!</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant