Load a Derby Lang dictionary from the file system.
$ npm install derby-lang-fs --save
Add the middleware to your server file:
var langFs = require('derby-lang-fs');
expressApp
// ...
// ...
.use(lang())
.use(langFs({
dir: '/path/to/dir'
}))
dir — The directory containing the language files.
path — The path to set the dictionary. Defaults to $lang.dict
.
Folder structure:
locale/
+-- en/
+-- app/
+-- index.json
+-- es/
+-- app/
+-- index.json
Model output:
{
"$lang": {
"dict": {
"strings": {
"en": {
"app": { /* index.json */ }
},
"es": {
"app": { /* index.json */ }
}
}
}
}
}
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";
};