diff --git a/core/server/i18n.js b/core/server/i18n.js index ac3a1afed4..e80b05102a 100644 --- a/core/server/i18n.js +++ b/core/server/i18n.js @@ -50,8 +50,10 @@ I18n = { * @param {string} msgPath Path with in the JSON language file to desired string (ie: "errors.init.jsNotBuilt") * @returns {string} */ - findString: function findString(msgPath) { - var matchingString, path; + findString: function findString(msgPath, opts) { + var options = _.merge({log: true}, opts || {}), + matchingString, path; + // no path? no string if (_.isEmpty(msgPath) || !_.isString(msgPath)) { chalk.yellow('i18n:t() - received an empty path.'); @@ -69,11 +71,13 @@ I18n = { // reassign matching object, or set to an empty string if there is no match matchingString = matchingString[key] || {}; }); - if (_.isObject(matchingString) || _.isEqual(matchingString, {})) { - logging.error(new errors.IncorrectUsageError({ - message: `i18n error: path "${msgPath}" was not found` - })); + if (options.log) { + logging.error(new errors.IncorrectUsageError({ + message: `i18n error: path "${msgPath}" was not found` + })); + } + matchingString = blos.errors.errors.anErrorOccurred; } @@ -81,7 +85,7 @@ I18n = { }, doesTranslationKeyExist: function doesTranslationKeyExist(msgPath) { - var translation = I18n.findString(msgPath); + var translation = I18n.findString(msgPath, {log: false}); return translation !== blos.errors.errors.anErrorOccurred; },