From c1c9438220e5b83c278cda5f2f7823a54e07e88c Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 17 Jan 2014 08:04:23 -0500 Subject: [PATCH] patching translator to ignore non-js files --- public/src/translator.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/public/src/translator.js b/public/src/translator.js index 8dd8671599..60994696b6 100644 --- a/public/src/translator.js +++ b/public/src/translator.js @@ -177,16 +177,24 @@ isServer = true; var utils = require('./utils.js'), + Meta = require('../../src/meta'), path = require('path'), fs = require('fs'), - Meta = require('../../src/meta'); + winston = require('winston'); - utils.walk(path.join(__dirname, '../../', 'public/language/' + (Meta.config.defaultLang || 'en')), function (err, data) { + utils.walk(path.join(__dirname, '../language', (Meta.config.defaultLang || 'en')), function (err, data) { var loaded = data.length; for (var d in data) { if (data.hasOwnProperty(d)) { - files.loaded[path.basename(data[d]).replace('.json', '')] = require(data[d]); + // Only load .json files + if (path.extname(data[d]) === '.json') { + files.loaded[path.basename(data[d]).replace('.json', '')] = require(data[d]); + } else { + if (process.env.NODE_ENV === 'development') { + winston.warn('[translator] Skipping language file: ' + path.relative(path.join(__dirname, '../language'), data[d])); + } + } } } });