Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eartharoid/i18n
⚡ A super fast, small, and simple message localisation library
https://github.com/eartharoid/i18n
fast i18n javascript nodejs
Last synced: 19 days ago
JSON representation
⚡ A super fast, small, and simple message localisation library
- Host: GitHub
- URL: https://github.com/eartharoid/i18n
- Owner: eartharoid
- License: mit
- Created: 2021-02-15T21:58:35.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-10-03T22:29:46.000Z (about 1 month ago)
- Last Synced: 2024-10-13T02:46:52.153Z (about 1 month ago)
- Topics: fast, i18n, javascript, nodejs
- Language: JavaScript
- Homepage: https://eartharoid.github.io/i18n
- Size: 968 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# i18n
A WIP super small and incredibly fast localisation library *with no documentation*.
## Goals
1. Speed
2. Small size
3. Simplicity, durability, and maintainability
4. Optional type-safety https://github.com/ivanhofer/typesafe-i18n
5. Optional build step## Features
- Simple JSON object input
- Simple string/interpolation format
- Pluralisation
- In-code formatters
- Bun for dev and TS testing## To-do
- i18nb encoder & decoder
- I18nClient
- `{< slot text >}` https://github.com/ivanhofer/typesafe-i18n/tree/main/packages/adapter-svelte#how-do-i-render-a-component-inside-a-translation
- Types generator
- CLI
- Vite plugin
- Svelte addon
- https://github.com/ivanhofer/typesafe-i18n?tab=readme-ov-file#why-does-the-translation-function-return-a-type-of-localizedstring-and-not-the-type-string-itself### Notes
- https://jsoneditoronline.org/indepth/parse/streaming-parser/
- https://en.wikipedia.org/wiki/JSON_streaming#Approaches## Crowdin
- https://crowdin.github.io/crowdin-cli/
- https://support.crowdin.com/bundles/
- https://store.crowdin.com/custom-bundle-generator
- https://store.crowdin.com/cff
- https://store.crowdin.com/configurable-json-yaml
- https://store.crowdin.com/yaml **supports comments for context**## v3
current:
```jsonc
[
"ns:circular_2",
{
"t": "This is two, ",
"p": [
[
13,
{
"g": "$t", // v or g
"d": {
"k": "circular_1"
}
}
]
]
}
]
```proposed:
```jsonc
[
"ns:circular_2",
[
{
"t": "This is two, " // t, s, v, or g
},
{
"g": "$t",
"d": {
"k": "circular_1"
}
}
]
]
```Placeholder positions aren't needed.
```js
// raw=true - return segments instead of string
[
{ text: 'Hello' },
{ slot: ['name', 'world'] }, // slots are omitted in non-raw (cooked..?) mode
{ text: '!' }
]
``````jsonc
// "Click {< here >} to {action} this {item}." // only works with 1 slot per string
// "Click {$slot(link, here)} to {action} this {item}." // not good, it's a valid getter
// "Click <{link} here> to {action} this {item}." // difficult
"Click {here} to {action} this {item}." // conflicts with "don't translate inside placeholders"
"Click to {action} this {item}."
"Click {% link; here %} to {action} this {item}."
```https://svelte.dev/docs/special-elements#slot
```svelte
```
```yaml
variable: Hello {name}
getter: I said "{$t(slot)}" # flatMap
slot: Please click or
```