-
-
Notifications
You must be signed in to change notification settings - Fork 12
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
Prevent baseTranslation
from flashing
#22
Comments
There will be no way to do not have But I agree that it is a bug since, at least, we should have Can I ask you to debug the source of the problem since you have a reproduction case? |
So I tested it again and I found that If I use // __layout.svelte
// something like this
<script context="module">
import { i18n } from '$lib/stores/i18n';
import { translationsLoading } from '@nanostores/i18n';
export const load = async () => {
...
// i18n.loading.get() --> false
if (i18n.loading.get()) {
await translationsLoading(i18n))
}
...
})
</script>
<main>
<slot />
</main> I'm guessing it is because the translation message is not used in the In the component I can await the translation and put a fallback placeholder when fetching the translation, but is it possible to await all translations from the |
Can you try to make PR? Sorry, I am busy on another open-source project now. |
Yup, sure, I'll try to make it, but I might need some guidance. Anyway, thanks for the great tools! Really appreciate it. |
Sure, feel free to ask questions. I will try to explain and guide you. |
I've recreated this issue in React, so it's not SveltKit problem. I think the loading.set(true/false) calls logic is broken in create-i18n. Can't yet figure how to fix. |
Can you try your app with adding this line? // @nanostores/i18n/create-i18n/index.js -- Line 99
async function getTranslation(code, components) {
await new Promise((resolve) => setTimeout(() => resolve(), 0)); // This Line
loading.set(true); It worked for React, an async issue. Changing of loading store to true. but component who used it, hasn't passed its callback yet. So it didn't know of loading store change. |
Hi @nymless, it doesn't work with SvelteKit. |
I'm using SvelteKit, and so far it's working fine unless for 1 problem.
When refreshing the page, it always flashes the
baseTranslation
before the current locale translation.The locale is persisted on the localStorage using
persistentAtom
.I also added
await translationsLoading(i18n)
but same result.And
i18n.loading.get()
always returningfalse
The text was updated successfully, but these errors were encountered: