i18next-sync-fs-backend
i18next backend which loads resources from filesystem synchronously, in contrast to i18next-node-fs-backend which is async (this is a fork). This avoids having your code wrapped in a i18next.init()
-callback. Supported filetypes:
Install
npm install i18next-sync-fs-backend
Usage
var i18n = require('i18next');
var Backend = require('i18next-sync-fs-backend');
i18n
.use(Backend)
.init({}, function(err){
});
console.log(i18n.t('key'));
Options
var i18n = require('i18next');
var Backend = require('i18next-sync-fs-backend');
i18n
.use(Backend)
.init({
backend: {
loadPath: '/locales/{{lng}}/{{ns}}.json',
addPath: '/locales/{{lng}}/{{ns}}.missing.json',
jsonIndent: 2
}
});