@abineo/sveltekit-i18n
TypeScript icon, indicating that this package has built-in type declarations

2.1.2 • Public • Published

⚠️ Archived and Unmaintained ⚠️

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

Sveltekit Auto-Typed i18n

npm

Vite Plugin to transpile translations from JSON into TypeScript for Sveltekit.

📖 Documentation

Notice

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

Installation

npm install --save-dev @abineo/sveltekit-i18n

Usage

// 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>

Contributing

If you think you found a bug: open a issue. Feature request are also welcome.

License

This library is distributed under the terms of the ISC License.
Find an easy explanation on choosealicense.com/licenses/isc.

Package Sidebar

Install

npm i @abineo/sveltekit-i18n

Weekly Downloads

4

Version

2.1.2

License

ISC

Unpacked Size

16.1 kB

Total Files

5

Last publish

Collaborators

  • christoph-jeanluc-schneider