cibernox / svelte-intl-precompile

I18n library for Svelte.js that analyzes your keys at build time for max performance and minimal footprint
https://svelte-intl-precompile.com
ISC License
274 stars 13 forks source link

Parameters not being replaced #43

Closed gwendal5 closed 2 years ago

gwendal5 commented 2 years ago

Hello. I'm having a problem with the $t(key, ops), it doesnt replace the parameters with the attributes I give it. Maybe I am missing something. Here is a codesandbox that shows the problem : https://codesandbox.io/s/falling-thunder-cdkpn1?file=/src/routes/__layout.svelte

icalvin102 commented 2 years ago

The locales have to be imported as import en from '$locales/en' instead of '../locales/en.json' in order for the svelteIntlPrecompile-plugin to do it's magic.

cibernox commented 2 years ago

@gwendal5 I edited your codesandbox: https://codesandbox.io/s/great-rubin-bjdelo?file=/src/routes/__layout.svelte

As @icalvin102 mentioned you should import from '$locales/fr' instead of from '../locales/fr.json'. Another thing that was wrong is that your configuration line (plugins: [precompileIntl("locales")]) specified that your locales were in /locales but you had them in /src/locales instead. I moved them to the root of the project.

cibernox commented 2 years ago

Hopefully this helps. I'm going to close this, please reopen if necessary.