This is a file system store for ilingo.
Table of Contents
npm install @ilingo/fs --save
import { Ilingo } from 'ilingo';
import FSStore from '@ilingo/fs';
const directory = 'language';
const ilingo = new Ilingo({
store: new FSStore({ directory }),
})
Locale strings should be stored in subdirectories as a group for each supported language (locale).
├── ...
└── language
├── de
│ ├── app.{ts,js,json,conf} # app group
│ └── forum.{ts,js,json,conf} # forum group
└── en
├── app.{ts,js,json,conf} # app group
└── forum.{ts,js,json,conf} # forum group
To get started, create e.g. a language directory somewhere in your project. Inside this directory, create a folder for each locale (e.g. en, de, ...), which should be supported.
The created folder represents a locale group. These groups do not have to follow any specific naming convention.
You should name the file according to the type of content it holds (e.g. app, forum, ...).
For example, let’s say you want to create a file containing error messages.
You might simply name it: error.{ts,js,json}
.
Each file should return an object containing an access key and a locale string.
app.{ts,js,json}
module.exports = {
'key': 'The locale string to be shown.'
}
The object can also be (deeply) nested ⚡.
app.{ts,js,json}
module.exports = {
'nested': {
'key': 'The locale string to be shown.'
}
}
It is also possible to use export default {...}
instead of module.exports = {...}
for script files.
Made with 💚
Published under MIT License.