sveltekit-i18n / lib

Internationalization library built for SvelteKit.
MIT License
447 stars 28 forks source link

Default locale flashes when reloading page #153

Closed MvRemmerden closed 9 months ago

MvRemmerden commented 9 months ago

When I reload the multi-page example on Netlify, the dropdown menu for selecting the locale flashes the default value.

I'm having the same problem when developing locally, and while the normal translated text is displayed perfectly fine without flashing, I couldn't figure out how to remove the flashing for the locale.

Kapture 2023-10-03 at 21 07 45

jarda-svoboda commented 9 months ago

Hi @MvRemmerden! I’m not 100% sure, but I think this one is about browser’s behavior - how it deals with preselected options in select component. For instance, I see no glitches in Safari on iOS.

https://github.com/sveltekit-i18n/lib/assets/20700514/53ed536c-c198-4f5f-a473-8022e23d1969

jarda-svoboda commented 9 months ago

Actually you could use selected option attribute (e.g. selected="{$locale === value}") to get rid of this behavior.. it seems that bind:value does not handle it by default..

jarda-svoboda commented 9 months ago

Fixed in the example