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 template elements are not localized #4

Open
tdulcet opened this issue May 24, 2024 · 2 comments
Open

HTML template elements are not localized #4

tdulcet opened this issue May 24, 2024 · 2 comments

Comments

@tdulcet
Copy link

tdulcet commented May 24, 2024

HTML template elements are not localized as expected:

<template>
	<span data-i18n="__MSG_example__">Please translate me!</span>
</template>

The issue is that they are not found by document.querySelectorAll:

Localizer/Localizer.js

Lines 283 to 286 in f6da4ca

document.querySelectorAll(`[${I18N_ATTRIBUTE}]`).forEach((currentElem) => {
const contentString = currentElem.dataset[I18N_DATASET];
replaceI18n(currentElem, contentString);
});

This affects my Thunderbird Send add-on, which uses an HTML template element in the popup. See tdulcet/Thunderbird-Send#14.

CC: @DenB10

@rugk
Copy link
Member

rugk commented May 25, 2024

Hmm interesting, it seems this is a feature of the template tag. Does it work if you set shadowrootmode to open?

@tdulcet
Copy link
Author

tdulcet commented May 25, 2024

Does it work if you set shadowrootmode to open?

No, setting it "open" breaks the template element and produces an exception: TypeError: can't access property "content", template is null. The solution might be to iterate over any template elements separately and then perform the query on each one.

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

2 participants