summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/output/website.js19
-rw-r--r--package.json3
2 files changed, 17 insertions, 5 deletions
diff --git a/lib/output/website.js b/lib/output/website.js
index bbb3fdc..32647f6 100644
--- a/lib/output/website.js
+++ b/lib/output/website.js
@@ -2,6 +2,7 @@ var _ = require('lodash');
var path = require('path');
var util = require('util');
var nunjucks = require('nunjucks');
+var I18n = require('i18n-t');
var Promise = require('../utils/promise');
var fs = require('../utils/fs');
@@ -29,6 +30,9 @@ function _WebsiteOutput() {
// Plugin instance for the default theme
this.defaultTheme;
+
+ // i18n for themes
+ this.i18n = new I18n();
}
util.inherits(_WebsiteOutput, Output);
@@ -68,15 +72,22 @@ WebsiteOutput.prototype.prepare = function() {
that.themeDefault? that.themeDefault.root : null
])
.compact()
- .map(templatesPath)
.uniq()
.value();
- that.env = new nunjucks.Environment(new nunjucks.FileSystemLoader(searchPaths));
+ // Load i18n
+ _.each(searchPaths.reverse(), function(searchPath) {
+ var i18nRoot = path.resolve(searchPath, '_i18n');
+
+ if (!fs.existsSync(i18nRoot)) return;
+ that.i18n.load(i18nRoot);
+ });
+
+
+ that.env = new nunjucks.Environment(new nunjucks.FileSystemLoader(_.map(searchPaths, templatesPath)));
that.env.addFilter('t', function(s) {
- // todo: i18n
- return s;
+ return that.i18n.t(that.book.config.get('language'), s);
});
// Transform an absolute path into a relative path
diff --git a/package.json b/package.json
index a5905c4..474effa 100644
--- a/package.json
+++ b/package.json
@@ -49,7 +49,8 @@
"cp": "0.2.0",
"cpr": "1.0.0",
"direction": "0.1.5",
- "moment": "2.11.2"
+ "moment": "2.11.2",
+ "i18n-t": "1.0.0"
},
"devDependencies": {
"eslint": "1.5.0",