Skip to content

psirenny/derby-lang-fs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Derby Lang FS

Load a Derby Lang dictionary from the file system.

Build Status

Installation

$ npm install derby-lang-fs --save

Usage

Add the middleware to your server file:

var langFs = require('derby-lang-fs');

expressApp
  // ...
  // ...
  .use(lang())
  .use(langFs({
    dir: '/path/to/dir'
  }))

Options

dir — The directory containing the language files.

path — The path to set the dictionary. Defaults to $lang.dict.

Example

Folder structure:

locale/
+-- en/
  +-- app/
    +-- index.json
+-- es/
  +-- app/
    +-- index.json

Model output:

{
  "$lang": {
    "dict": {
      "strings": {
        "en": {
          "app": { /* index.json */ }
        },
        "es": {
          "app": { /* index.json */ }
        }
      }
    }
  }
}

Custom message formats

You may also include custom messageformat.js select functions as .js files. This is particularly useful if you have a new language or want to override the default messageformat select functions:

Folder structure:

locale/
+-- cu.js

And within cu.js:

module.exports = function (n) {
  return n === 1 ? "one" : "other";
};

About

Filesystem translation loader for Derby Lang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published