Closed Reikooters closed 2 years ago
Can you change your
register("en", () => import("./locales/en.json"));
register("es", () => import("./locales/es.json"));
to
register("en", () => import("$locales/en"));
register("es", () => import("$locales/es"));
?
Since you are using vite, the info in https://svelte-intl-precompile.com/en/docs/configuration should work for you.
In fact calling registerAll
is what I recommend unless you have a reason not to.
Closing this due to inactivity. Feel free to reopen if still relevant.
Hi there, just trying out your library but I'm a bit confused as to what I've missed.
The problem I'm having is that the value placeholders aren't being populated. i.e. the text shown is the literal "Welcome back, {name}" rather than replacing {name} with the value I passed in.
I'm actually using Routify v2, not SvelteKit - does that matter? Note that svelte-i18n works fine. Testing with just an empty Routify project to try it out, not trying to add this to an existing application. I've never used SvelteKit before.
Here are the steps I followed to reproduce it.
Made a new routify project and installed this dependency
Version of svelte-intl-precompile installed is 0.9.2.
As per the documentation ( https://svelte-intl-precompile.com/en/docs/getting-started ), in my vite.config.js I've added precompileIntl as below:
/vite.config.js
/src/App.svelte:
/src/locales/en.json (copied content from the docs)
/src/locales/es.json (same content)
/src/pages/index.svelte
Then run and access localhost:5000
The text for "page.title" appears fine as it doesn't need any values. However "login-success-msg" outputs the literal "Welcome back, {name}" without replacing {name} with "friend".
Not sure if it's some incompatibility with Routify or I've missed something. Let me know if there's a way I can give any additional information to troubleshoot.
This is a new project I'm working on and it's my first time using svelte-i18n as well - I came across svelte-intl-precompile via the issues in that repository. For now I'll use svelte-i18n to get started, but this project looks promising so hope to switch over later.