Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/noelmugnier/svelte-translate
Use a dynamic translation service (loaded from xx-XX.json files) and fallback to the text in html tags if no translations are provided.
https://github.com/noelmugnier/svelte-translate
svelte sveltejs translate
Last synced: 2 days ago
JSON representation
Use a dynamic translation service (loaded from xx-XX.json files) and fallback to the text in html tags if no translations are provided.
- Host: GitHub
- URL: https://github.com/noelmugnier/svelte-translate
- Owner: noelmugnier
- License: mit
- Created: 2021-09-18T11:17:42.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2021-10-01T14:03:20.000Z (about 3 years ago)
- Last Synced: 2024-10-16T06:31:06.518Z (about 1 month ago)
- Topics: svelte, sveltejs, translate
- Language: TypeScript
- Homepage:
- Size: 874 KB
- Stars: 10
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Svelte Translate (inspired by angular i18n and svelte-i18n)
Dynamic translation service (loaded from xx-XX.json files) and fallback to the text in html tags if no translations are provided.
# ICU support (FormatJS)
This component use [formatjs](https://github.com/formatjs/formatjs) to handle complex formatting (plural, select, etc...)
# Usages
```js
import {
i18n,
def,
i18nStore,
languages,
DynamicTranslatedApp,
getLocaleFromNavigator
} from "svelte-translate";import LanguageSelector from "./LanguageSelector.svelte";
import enGB from './../public/lang/en-GB.json';
import frFR from './../public/lang/fr-FR.json';let count = 0;
i18nStore.addTranslations("en-GB", enGB);
i18nStore.addTranslations("fr-FR", frFR);```
```html
Default text with bindings {sampleValue}
Text without complex construction```
Then add two json files (fr-FR.json/en-GB.json) in public/lang folder containing your translations :```json
{
"myid": "Custom translation text with bindings {sampleValue}",
"simpleid": "Custom text without bindings",
}
```# TODO
* [ ] support context/description in def() helper in order to extract them and complete xlf files require a fork on xliff library to use custom attributes