mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-22 18:43:29 +00:00
Normalize language to support: "fr-FR"
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user