Normalize language to support: "fr-FR"

This commit is contained in:
Samy Pessé
2015-01-23 23:06:10 +01:00
parent f12163534d
commit 2bb2a2a330
2 changed files with 10 additions and 3 deletions
+5
View File
@@ -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;
+5 -3
View File
@@ -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,