https://github.com/acryps/language
Translations made easy
https://github.com/acryps/language
Last synced: 4 months ago
JSON representation
Translations made easy
- Host: GitHub
- URL: https://github.com/acryps/language
- Owner: acryps
- Created: 2023-07-31T07:45:24.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-19T09:10:34.000Z (about 2 years ago)
- Last Synced: 2025-02-25T21:33:14.862Z (over 1 year ago)
- Language: TypeScript
- Size: 22.5 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# acryps language
Translations made easy, languages based on ISO 639.
```
'Hello World'
.german('Hallo Welt')
.italian('Ciao mondo')
.greek('Γεια σου κόσμε')
.japanese('ハローワールド')
```
Just make sure to set the active language before the strings are resolved
```
import { Language, languages } from '@acryps/language';
Language.active = languages.german;
const count = 3;
console.log(
`${count} items in the cart`
.german(`Warenkorb: ${count} Stück`)
) // → Warenkorb: 3 Stück
```
Can be used in the browser and server-side!
Another handy property found on all languages is the natural writing direction:
```
document.documentElement.dir = Language.active.direction;
```