From d5af510a787a72e9a01735c59e8798d034fec519 Mon Sep 17 00:00:00 2001 From: Andy Lulham Date: Tue, 27 May 2014 14:50:48 +0100 Subject: [PATCH] =?UTF-8?q?[#318]=20Use=20config=20for=20setting=20locales?= =?UTF-8?q?=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …and ensure we set locale *after* config is fully loaded. --- lib/i18n.js | 5 +++-- run.js | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/i18n.js b/lib/i18n.js index 9388df77..1f4f79d1 100644 --- a/lib/i18n.js +++ b/lib/i18n.js @@ -1,5 +1,6 @@ var i18n = require('i18n-abide') , fs = require('fs') + , config = require('./config') , locales , _ = require('underscore') ; @@ -7,7 +8,7 @@ var i18n = require('i18n-abide') module.exports = { locales: function() { locales = locales || - _.without(fs.readdirSync(__dirname + '/../locale'), 'templates'); + config.get('locales'); return locales; }, @@ -16,7 +17,7 @@ module.exports = { app.use(i18n.abide({ supported_languages: locales, - default_lang: 'en', + default_lang: _.first(locales), translation_directory: 'locale' })); } diff --git a/run.js b/run.js index 06927f7b..1dea9d0a 100644 --- a/run.js +++ b/run.js @@ -1,8 +1,7 @@ var model = require('./lib/model').OpenDataCensus - , app = require('./app').app , census = require('./routes/census') , config = require('./lib/config') - ; + ; // Booting up // ======================================================== @@ -15,6 +14,9 @@ model.load(function(err) { console.error('Failed to load dataset info'); throw err; } + + app = require('./app').app + // Passport Auth Stuff (Facebook etc) // set up here rather than app.js as must be after config load to // get site_url