mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
Do not log error if i18n.doesTranslationKeyExist
is called
no issue - when calling `doesTranslationKeyExist`, we want to know if a key exists, we don't want to log if the key was not found - this can mess up the server log
This commit is contained in:
parent
76689ecbee
commit
c4044aa498
@ -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;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user