Fixed i18n-coverage bug

Added analysis of the translation of all available properties
This commit is contained in:
nixel2007 2014-12-17 23:21:54 +03:00
parent 30ed0a0ead
commit 97cdb76b82

View file

@ -379,8 +379,26 @@ class CocoModel extends Backbone.Model
updateI18NCoverage: ->
i18nObjects = @findI18NObjects()
return unless i18nObjects.length
langCodeArrays = (_.keys(i18n) for i18n in i18nObjects)
@set('i18nCoverage', _.intersection(langCodeArrays...))
langCodeArrays = (_.keys(i18n) for i18n in i18nObjects)
langCodeArray = langCodeArrays[0]
temp_i18nCoverage = []
schemaProps = (schemaProp for schemaProp in this.schema().properties.i18n.props when this.attributes.hasOwnProperty(schemaProp))
for lang in langCodeArray
langProps = i18n[lang]
allProps = true
for prop in schemaProps
if not langProps.hasOwnProperty(prop)
allProps = false
break
if allProps
temp_i18nCoverage.push lang
@set('i18nCoverage', temp_i18nCoverage)
findI18NObjects: (data, results) ->
data ?= @attributes