mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -05:00
Added i18nCoverage backend support.
This commit is contained in:
parent
36ea415dbf
commit
0dc050abca
7 changed files with 26 additions and 1 deletions
|
@ -284,6 +284,7 @@ class CocoModel extends Backbone.Model
|
|||
if schema.items and _.isArray data
|
||||
sum += @populateI18N(value, schema.items, path+'/'+index) for value, index in data
|
||||
|
||||
@updateI18NCoverage()
|
||||
sum
|
||||
|
||||
@getReferencedModel: (data, schema) ->
|
||||
|
|
|
@ -253,6 +253,7 @@ c.extendSearchableProperties LevelSchema
|
|||
c.extendVersionedProperties LevelSchema, 'level'
|
||||
c.extendPermissionsProperties LevelSchema, 'level'
|
||||
c.extendPatchableProperties LevelSchema
|
||||
c.extendTranslationCoverageProperties LevelSchema
|
||||
|
||||
module.exports = LevelSchema
|
||||
|
||||
|
|
|
@ -143,6 +143,10 @@ me.getLanguageCodeArray = ->
|
|||
return Language.languageCodes
|
||||
|
||||
me.getLanguagesObject = -> return Language
|
||||
|
||||
me.extendTranslationCoverageProperties = (schema) ->
|
||||
schema.properties = {} unless schema.properties?
|
||||
schema.properties.i18nCoverage = { title: 'i18n Coverage', type: 'array', items: { type: 'string' }}
|
||||
|
||||
# OTHER
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ LevelSchema.plugin(plugins.PermissionsPlugin)
|
|||
LevelSchema.plugin(plugins.VersionedPlugin)
|
||||
LevelSchema.plugin(plugins.SearchablePlugin, {searchable: ['name', 'description']})
|
||||
LevelSchema.plugin(plugins.PatchablePlugin)
|
||||
LevelSchema.plugin(plugins.TranslationCoveragePlugin)
|
||||
|
||||
LevelSchema.post 'init', (doc) ->
|
||||
if _.isString(doc.get('nextLevel'))
|
||||
|
|
|
@ -9,5 +9,6 @@ ThangTypeSchema.plugin plugins.NamedPlugin
|
|||
ThangTypeSchema.plugin plugins.VersionedPlugin
|
||||
ThangTypeSchema.plugin plugins.SearchablePlugin, {searchable: ['name']}
|
||||
ThangTypeSchema.plugin plugins.PatchablePlugin
|
||||
ThangTypeSchema.plugin plugins.TranslationCoveragePlugin
|
||||
|
||||
module.exports = mongoose.model('thang.type', ThangTypeSchema)
|
||||
|
|
|
@ -35,6 +35,7 @@ ThangTypeHandler = class ThangTypeHandler extends Handler
|
|||
'rasterIcon'
|
||||
'featureImage'
|
||||
'spriteType'
|
||||
'i18nCoverage'
|
||||
]
|
||||
|
||||
hasAccess: (req) ->
|
||||
|
|
|
@ -281,7 +281,7 @@ module.exports.SearchablePlugin = (schema, options) ->
|
|||
|
||||
searchable = options.searchable
|
||||
unless searchable
|
||||
throw Error('SearchablePlugin options must include list of searchable properties.')
|
||||
throw new Error('SearchablePlugin options must include list of searchable properties.')
|
||||
|
||||
index = {}
|
||||
|
||||
|
@ -307,3 +307,19 @@ module.exports.SearchablePlugin = (schema, options) ->
|
|||
@index = @getOwner() unless access
|
||||
|
||||
next()
|
||||
|
||||
module.exports.TranslationCoveragePlugin = (schema, options) ->
|
||||
|
||||
schema.uses_coco_translation_coverage = true
|
||||
schema.set('autoIndex', true)
|
||||
|
||||
index = {}
|
||||
|
||||
if schema.uses_coco_versions
|
||||
if not schema.uses_coco_names
|
||||
throw Error('If using translation coverage and versioning, should also use names for indexing.')
|
||||
index.slug = 1
|
||||
|
||||
index.i18nCoverage = 1
|
||||
|
||||
schema.index(index, {sparse: true, name: 'translation coverage index', background: true})
|
Loading…
Reference in a new issue