@ilingo/fs
TypeScript icon, indicating that this package has built-in type declarations

4.3.1 • Public • Published

@ilingo/fs 🗃️

npm version main codecov Known Vulnerabilities Conventional Commits

This is a file system store for ilingo.

Table of Contents

Installation

npm install @ilingo/fs --save

Usage

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.

License

Made with 💚

Published under MIT License.

Package Sidebar

Install

npm i @ilingo/fs

Weekly Downloads

301

Version

4.3.1

License

MIT

Unpacked Size

36.5 kB

Total Files

19

Last publish

Collaborators

  • tada5hi