svelte-i18n
svelte-i18n copied to clipboard
Disable automatic "lang" attribute setting
Is your feature request related to a problem? Please describe.
I am using this library for an embedded widget that is integrated into other companies websites.
I only just realized now that this library is automatically setting the "lang" attribute on the html tag, whenever the internalLocale is changed.
This is mixing up our customers websites.
Describe the solution you'd like I would like to have the option in the init method to disable the automatic attribute setting.
How important is this feature to you? Very important as there is currently no other way to do it.
@kaisermann First I thought I could avoid this problem in my application but now it seems that even with no rendering of my application this library is being executed when the JavaScript ran. That means, that it sets the HTML "lang" attribute to null or empty string even though there is never a call of the "init" method. Do you have any ideas how to fix this?
I encountered the same problem and temporarily covered the relevant code with pnpm patch, specifically this line below.
https://github.com/kaisermann/svelte-i18n/blob/5afd1f8677c8371dcbec5b5b9a7175500f17591b/src/runtime/stores/locale.ts#L39
If I submit a PR to add an option to disable it, would @kaisermann be willing to merge it?
Can you share more about why it's a problem to automatically update the lang attribute? I'd expect it'd generally be desirable to do so and we try to avoid adding options unless it's really needed
Can you share more about why it's a problem to automatically update the
langattribute? I'd expect it'd generally be desirable to do so and we try to avoid adding options unless it's really needed
Simply put, the script I inject into the webpage through a Chrome extension pops up a panel, and the panel itself supports multiple languages. Unfortunately, automatically modifying the document attribute causes the website's own language to change as well, which is not the intended behavior.