Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tada5hi/ilingo
Ilingo is a lightweight library for translation and internationalization.
https://github.com/tada5hi/ilingo
bilingual client-side i18n javascript language locale server-side translate translation typescript
Last synced: 20 days ago
JSON representation
Ilingo is a lightweight library for translation and internationalization.
- Host: GitHub
- URL: https://github.com/tada5hi/ilingo
- Owner: tada5hi
- License: mit
- Created: 2022-02-25T09:18:18.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-10-11T00:38:46.000Z (about 1 month ago)
- Last Synced: 2024-10-12T18:57:33.669Z (about 1 month ago)
- Topics: bilingual, client-side, i18n, javascript, language, locale, server-side, translate, translation, typescript
- Language: TypeScript
- Homepage:
- Size: 4.9 MB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: SECURITY.md
Awesome Lists containing this project
README
# ilingo 📚
A lightweight library for translation and internationalization.
**Table of Contents**
- [Usage](#usage)
- [Packages](#packages)
- [Core](#core-)
- [FS](#fs-)
- [Vue](#vue-)
- [Vuelidate](#vuelidate-)
- [License](#license)## Usage
Create an instance and set the default locale.
```typescript
import { Ilingo } from 'ilingo';const ilingo = new Ilingo({
locale: 'en'
})
```The **default** (memory-) store can be initialized with some default data.
```typescript
import { Ilingo, MemoryStore } from 'ilingo';const store = new MemoryStore({
data: {
// locale: de
de: {
// group: app
app: {
key: 'Hallo mein Name ist {{name}}'
}
},
// locale: en
en: {
app: {
key: 'Hello my name is {{name}}'
}
},
}
});const ilingo = new Ilingo({
store,
locale: 'en'
});
```To retrieve text from any of the language files, simply pass the filename/group and the access key
as the first parameter, separated by a period (.).After that you can simply access the locale string, as described in the following:
```typescript
import { Ilingo } from 'ilingo';const ilingo = new Ilingo({
// ...
});await ilingo.get({
group: 'app',
key: 'key'
});
// Hello my name is {{name}}await ilingo.get({
group: 'app',
key: 'key',
data: {
name: 'Peter'
}
});
// Hello my name is Peterawait ilingo.get({
group: 'app',
key: 'key',
data: {
name: 'Peter'
},
locale: 'de'
});
// Hallo mein Name ist Peter
```To learn more about usage, inspect the [README.md](./packages/ilingo/README.md) of the core package.
## Packages
The repository contains the following packages:
### Core 💬
**`ilingo`**
This package contains the base library
for translation and internationalization[Documentation](./packages/ilingo/README.md)
### FS 🗃️
**`@ilingo/fs`**
This package contains a file-system store for the
ilingo package.[Documentation](./packages/fs/README.md)
### Vue 🖌️
**`@ilingo/vue`**
This package contains an adapter for vue.
[Documentation](./packages/vue/README.md)
### Vuelidate 🎉
**`@ilingo/vuelidate`**
This package contains an adapter for the vuelidate library.
[Documentation](./packages/vuelidate/README.md)
## License
Made with 💚
Published under [MIT License](./LICENSE).