diff --git a/core/server/i18n.js b/core/server/i18n.js index ad1ebdc031..d69cceeb88 100644 --- a/core/server/i18n.js +++ b/core/server/i18n.js @@ -5,6 +5,8 @@ var supportedLocales = ['en'], fs = require('fs'), chalk = require('chalk'), MessageFormat = require('intl-messageformat'), + logging = require('./logging'), + errors = require('./errors'), // TODO: fetch this dynamically based on overall blog settings (`key = "default_locale"`) in the `settings` table currentLocale = 'en', @@ -65,12 +67,14 @@ I18n = { path = msgPath.split('.'); path.forEach(function (key) { // reassign matching object, or set to an empty string if there is no match - matchingString = matchingString[key] || null; + matchingString = matchingString[key] || {}; }); - if (_.isNull(matchingString)) { - console.error('Unable to find matching path [' + msgPath + '] in locale file.\n'); - matchingString = 'i18n error: path "' + msgPath + '" was not found.'; + if (_.isObject(matchingString) || _.isEqual(matchingString, {})) { + logging.error(new errors.IncorrectUsageError({ + message: `i18n error: path "${msgPath}" was not found` + })); + matchingString = blos.errors.errors.anErrorOccurred; } return matchingString;