UNPKG

get-translation

Version:
50 lines (40 loc) 997 B
/** * We need to properly check for the syntax in some translations. * * @constructor Syntax */ function Syntax() {} /** * Developer sometime defines same key in two different files. But they use two * different sets of variables. It should throw an error when that happens. * This method helps checking if there is any error duplicate in the source * files by providing newTranslations. * * @param {Object} newTranslations * @param {String} key * @param {Array} vars * @return {Boolean} * @api public */ Syntax.prototype.hasErrorDuplicate = function(newTranslations, key, vars) { if(typeof newTranslations[key] === 'undefined') { return false; } if(vars.length !== newTranslations[key].vars.length) { return true; } for(var i in vars) { if(newTranslations[key].vars[i] !== vars[i]) { return true; } } return false; }; /** * Export instance */ module.exports = new Syntax; /** * Export constructor */ module.exports.Syntax = Syntax;