sveltekit functions files.ts not get $LL string translated #674
-
Hi all,
the translation work well in +page.svelte but when using in functions.ts, it get no value. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
If you call |
Beta Was this translation helpful? Give feedback.
-
I am on a similar journey as above and not sure what I am doing wrong.
<script lang="ts">
import { LL, setLocale, locale } from '$i18n/i18n-svelte.js';
setLocale('en');
$: {
console.log($locale);
console.log($LL.HI({ name: 'Svelte' }));
}
</script>
<div id="app">
<p>{$LL.HI({name: 'Svelte'})}</p>
</div> The console output: en
No output for the second console log and nothing is rendered in the browser either. Here's my sveltekit config import adapter from '@sveltejs/adapter-static';
import { vitePreprocess } from '@sveltejs/kit/vite';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
pages: 'build',
assets: 'build',
fallback: "index.html",
precompress: false,
strict: true
}),
alias: {
'$components': './src/components/',
'$lib': './src/lib/',
'$stores': './src/stores/',
'$i18n': './src/i18n/',
},
},
build: {
rollupOptions: {
chunkSizeWarningLimit: 1000,
},
},
};
export default config; and the .typesafe-i18n.json
|
Beta Was this translation helpful? Give feedback.
If you call
getStore(LL)
inside theagree
function it should work. I'm assuming$LL
gets initialized beforetypeasfe-i18n
is initialized. Therefore nolocale
is set and you see an empty output.