Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nubolab-ffwd/svelte-fluent
svelte-fluent is a powerful localization library for Svelte and SvelteKit that enables you to integrate translations using Mozilla's natural-sounding Fluent syntax easily.
https://github.com/nubolab-ffwd/svelte-fluent
fluent formatting ftl globalization i18n internationalization javascript l10n language locale localization rollup sapper svelte sveltejs sveltekit translation vite
Last synced: 19 days ago
JSON representation
svelte-fluent is a powerful localization library for Svelte and SvelteKit that enables you to integrate translations using Mozilla's natural-sounding Fluent syntax easily.
- Host: GitHub
- URL: https://github.com/nubolab-ffwd/svelte-fluent
- Owner: nubolab-ffwd
- License: mit
- Created: 2020-07-01T11:31:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-10-29T09:20:13.000Z (about 1 month ago)
- Last Synced: 2024-10-29T10:56:34.781Z (about 1 month ago)
- Topics: fluent, formatting, ftl, globalization, i18n, internationalization, javascript, l10n, language, locale, localization, rollup, sapper, svelte, sveltejs, sveltekit, translation, vite
- Language: Svelte
- Homepage: https://nubolab-ffwd.github.io/svelte-fluent/
- Size: 33.1 MB
- Stars: 96
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-svelte - svelte-fluent - Components for easy integration of [Fluent](https://projectfluent.org/) localization. (Utilities / Internationalization)
README
# Svelte Fluent [![Documentation](https://img.shields.io/badge/-Documentation-blue)](https://nubolab-ffwd.github.io/svelte-fluent/) [![svelte-fluent on npm](https://img.shields.io/npm/v/@nubolab-ffwd/svelte-fluent)](https://www.npmjs.com/package/@nubolab-ffwd/svelte-fluent) ![Tests](https://github.com/nubolab-ffwd/svelte-fluent/workflows/Tests/badge.svg) [![Svelte v5](https://img.shields.io/badge/svelte-v5-blueviolet?logo=svelte)](https://svelte.dev)
`svelte-fluent` is a powerful localization library for
[Svelte](https://svelte.dev/) and [SvelteKit](https://kit.svelte.dev/)
that enables you to integrate translations using Mozilla's natural-sounding Fluent syntax easily.## Installation
```
npm install --save-dev @nubolab-ffwd/svelte-fluent
npm install --save jsdom
```## Documentation
Documentation can be found at https://nubolab-ffwd.github.io/svelte-fluent/
## Example
```svelte
import { FluentBundle, FluentResource } from '@fluent/bundle';
import { Localized, initFluentContext, createSvelteFluent } from '@nubolab-ffwd/svelte-fluent';export let userName = 'Anna';
export let userGender = 'female';
export let photoCount = 3;const translations = `
# Simple things are simple.
hello-user = Hello, {$userName}!# Complex things are possible.
shared-photos =
{$userName} {$photoCount ->
[one] added a new photo
*[other] added {$photoCount} new photos
} to {$userGender ->
[male] his stream
[female] her stream
*[other] their stream
}.
`;
const bundle = new FluentBundle('en');
bundle.addResource(new FluentResource(translations));initFluentContext(() => createSvelteFluent([bundle]));
```