diff --git a/src/i18n.js b/src/i18n.js index d0668814b1..238df963df 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -5,19 +5,22 @@ var fs = require('fs'), shared = require('habitrpg-shared'), translations = {}; +var localePath = path.join(__dirname, "/../node_modules/habitrpg-shared/locales/") + var loadTranslations = function(locale){ - var files = fs.readdirSync(path.join(__dirname, "/../node_modules/habitrpg-shared/locales/", locale)); + var files = fs.readdirSync(path.join(localePath, locale)); translations[locale] = {}; _.each(files, function(file){ - _.merge(translations[locale], require(path.join(__dirname, "/../node_modules/habitrpg-shared/locales/", locale, file))); + if(path.extname(file) !== '.json') return; + _.merge(translations[locale], require(path.join(localePath, locale, file))); }); }; // First fetch english so we can merge with missing strings in other languages loadTranslations('en'); -fs.readdirSync(path.join(__dirname, "/../node_modules/habitrpg-shared/locales/")).forEach(function(file) { - if(file === 'en' || file === 'README.md') return; +fs.readdirSync(localePath).forEach(function(file) { + if(file === 'en' || fs.statSync(path.join(localePath, file)).isDirectory() === false) return; loadTranslations(file); // Merge missing strings from english _.defaults(translations[file], translations.en);