.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
Vite Plugin to transpile translations from JSON into TypeScript for Sveltekit.
Use this library with causion. There are lot of tests that need to be written and possibly some bugs to be fixed. But we do not expect to introduce breaking changes.
Found a bug? -> Contributing
npm install --save-dev @abineo/sveltekit-i18n
// vite.config.ts
import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig } from 'vite';
import i18n from '@abineo/sveltekit-i18n';
const config: UserConfig = {
plugins: [i18n({
{
src: './src/lib/i18n/src',
out: './src/lib/i18n',
folder: 'dist',
defaultParamType: 'string',
createGitignore: true,
createSummary: true,
defaultLanguage: 'de-CH',
}
}), sveltekit()],
};
export default config;
// src/lib/i18n/src/de-CH.jsonc
{
"strongly": {
"typed": {
"translations": "Lorem ipsum dolor sit amet."
}
},
"even": {
"supports": "what? { thing: string }!"
}
}
<script lang="ts">
import { selectedLanguage, t } from '$lib/i18n';
selectedLanguage.set('de-CH');
</script>
<main>
<p>{$t.strongly.typed.translations}</p>
<p>{$t.even supports('parameters')}</p>
<!-- Output: <p>what? parameters!</p> -->
</main>
If you think you found a bug: open a issue. Feature request are also welcome.
This library is distributed under the terms of the ISC License.
Find an easy explanation on choosealicense.com/licenses/isc.