diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-01-23 23:06:10 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-01-23 23:06:10 +0100 |
commit | 2bb2a2a330ca065fdf8a928c9eb22660578951c7 (patch) | |
tree | 4de7451a65cd954f83e434eee813cfb0950ede3c /lib | |
parent | f12163534d877f627dbbf25eb455cb851e821f31 (diff) | |
download | gitbook-2bb2a2a330ca065fdf8a928c9eb22660578951c7.zip gitbook-2bb2a2a330ca065fdf8a928c9eb22660578951c7.tar.gz gitbook-2bb2a2a330ca065fdf8a928c9eb22660578951c7.tar.bz2 |
Normalize language to support: "fr-FR"
Diffstat (limited to 'lib')
-rw-r--r-- | lib/configuration.js | 5 | ||||
-rw-r--r-- | lib/generators/website.js | 8 |
2 files changed, 10 insertions, 3 deletions
diff --git a/lib/configuration.js b/lib/configuration.js index 4c441f0..d5406c5 100644 --- a/lib/configuration.js +++ b/lib/configuration.js @@ -106,6 +106,11 @@ Configuration.prototype.getStructure = function(name) { return this.options.structure[name].split(".").slice(0, -1).join("."); }; +// Return normalized language +Configuration.prototype.normalizeLanguage = function() { + return _.first(this.options.language.split("-")).toLowerCase(); +}; + // Install plugins Configuration.prototype.installPlugins = function(options) { var that = this; diff --git a/lib/generators/website.js b/lib/generators/website.js index 5dffd14..bb2daa1 100644 --- a/lib/generators/website.js +++ b/lib/generators/website.js @@ -70,6 +70,8 @@ Generator.prototype.prepareTemplateEngine = function() { return fs.readdir(path.resolve(__dirname, "../../theme/i18n")) .then(function(locales) { + var language = that.book.config.normalizeLanguage(); + locales = _.chain(locales) .map(function(local) { local = path.basename(local, ".json"); @@ -78,8 +80,8 @@ Generator.prototype.prepareTemplateEngine = function() { .object() .value(); - if (!_.contains(_.keys(locales), that.options.language)) { - that.book.logWarn("Language '"+that.options.language+"' is not available as a layout locales ("+_.keys(locales).join(", ")+")"); + if (!_.contains(_.keys(locales), language) && language != "en") { + that.book.logWarn("Language '"+language+"' is not available as a layout locales (en, "+_.keys(locales).join(", ")+")"); } var folders = _.chain(that.templates) @@ -215,7 +217,7 @@ Generator.prototype._writeTemplate = function(tpl, options, output, interpolate) title: that.options.title, description: that.options.description, - language: that.options.language, + language: that.book.config.normalizeLanguage(), glossary: that.book.glossary, |