mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Using the new i18n utility function everywhere. Fixed big bug with spell palette i18n.
This commit is contained in:
parent
2d848b4cce
commit
c8103154a9
9 changed files with 32 additions and 29 deletions
|
@ -1,6 +1,6 @@
|
||||||
ScriptModule = require './ScriptModule'
|
ScriptModule = require './ScriptModule'
|
||||||
{me} = require 'lib/auth'
|
{me} = require 'lib/auth'
|
||||||
util = require 'lib/utils'
|
utils = require 'lib/utils'
|
||||||
|
|
||||||
module.exports = class SpritesScriptModule extends ScriptModule
|
module.exports = class SpritesScriptModule extends ScriptModule
|
||||||
@neededFor: (noteGroup) ->
|
@neededFor: (noteGroup) ->
|
||||||
|
@ -36,9 +36,9 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
||||||
responses = sprite.say.responses
|
responses = sprite.say.responses
|
||||||
responses = [] unless script.skippable or responses
|
responses = [] unless script.skippable or responses
|
||||||
for response in responses ? []
|
for response in responses ? []
|
||||||
response.text = response.i18n?[me.lang()]?.text ? response.text
|
response.text = utils.i18n response, 'text'
|
||||||
text = util.i18n(sprite.say, 'text')
|
text = utils.i18n sprite.say, 'text'
|
||||||
blurb = util.i18n(sprite.say, 'blurb')
|
blurb = utils.i18n sprite.say, 'blurb'
|
||||||
sound = sprite.say.sound # TODO support sound i18n
|
sound = sprite.say.sound # TODO support sound i18n
|
||||||
note =
|
note =
|
||||||
channel: 'level-sprite-dialogue'
|
channel: 'level-sprite-dialogue'
|
||||||
|
|
|
@ -66,5 +66,4 @@ module.exports.i18n = (say, target, language=me.lang(), fallback='en') ->
|
||||||
return fallforwardResult if fallforwardResult?
|
return fallforwardResult if fallforwardResult?
|
||||||
return fallbackResult if fallbackResult?
|
return fallbackResult if fallbackResult?
|
||||||
return say[target] if target of say
|
return say[target] if target of say
|
||||||
return say.text if 'text' of say
|
|
||||||
null
|
null
|
||||||
|
|
|
@ -6,5 +6,5 @@ ul(class="nav nav-pills" + (tabbed ? ' multiple-tabs' : ''))
|
||||||
h4= group
|
h4= group
|
||||||
.tab-content
|
.tab-content
|
||||||
each slug, group in entryGroupSlugs
|
each slug, group in entryGroupSlugs
|
||||||
div(id="palette-tab-" + slug, class="tab-pane" + (group == "this" || slug == "available-spells" ? " active" : ""))
|
div(id="palette-tab-" + slug, class="tab-pane" + (group == "this" || slug == defaultGroupSlug ? " active" : ""))
|
||||||
div(class="properties properties-" + slug)
|
div(class="properties properties-" + slug)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
View = require 'views/kinds/CocoView'
|
View = require 'views/kinds/CocoView'
|
||||||
template = require 'templates/play/level/goals'
|
template = require 'templates/play/level/goals'
|
||||||
{me} = require 'lib/auth'
|
{me} = require 'lib/auth'
|
||||||
|
utils = require 'lib/utils'
|
||||||
|
|
||||||
stateIconMap =
|
stateIconMap =
|
||||||
incomplete: 'icon-minus'
|
incomplete: 'icon-minus'
|
||||||
|
@ -31,7 +32,7 @@ module.exports = class GoalsView extends View
|
||||||
state = e.goalStates[goal.id]
|
state = e.goalStates[goal.id]
|
||||||
continue if goal.hiddenGoal and state.status isnt 'failure'
|
continue if goal.hiddenGoal and state.status isnt 'failure'
|
||||||
continue if goal.team and me.team isnt goal.team
|
continue if goal.team and me.team isnt goal.team
|
||||||
text = goal.i18n?[me.lang()]?.name ? goal.name
|
text = utils.i18n goal, 'name'
|
||||||
if state.killed
|
if state.killed
|
||||||
dead = _.filter(_.values(state.killed)).length
|
dead = _.filter(_.values(state.killed)).length
|
||||||
targeted = _.values(state.killed).length
|
targeted = _.values(state.killed).length
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
View = require 'views/kinds/ModalView'
|
View = require 'views/kinds/ModalView'
|
||||||
template = require 'templates/play/level/modal/docs'
|
template = require 'templates/play/level/modal/docs'
|
||||||
Article = require 'models/Article'
|
Article = require 'models/Article'
|
||||||
|
utils = require 'lib/utils'
|
||||||
|
|
||||||
# let's implement this once we have the docs database schema set up
|
# let's implement this once we have the docs database schema set up
|
||||||
|
|
||||||
module.exports = class DocsModal extends View
|
module.exports = class DocsModal extends View
|
||||||
template: template
|
template: template
|
||||||
id: 'docs-modal'
|
id: 'docs-modal'
|
||||||
|
|
||||||
shortcuts:
|
shortcuts:
|
||||||
'enter': 'hide'
|
'enter': 'hide'
|
||||||
|
|
||||||
|
@ -25,8 +26,8 @@ module.exports = class DocsModal extends View
|
||||||
@docs = specific.concat(general)
|
@docs = specific.concat(general)
|
||||||
marked.setOptions {gfm: true, sanitize: false, smartLists: true, breaks: false}
|
marked.setOptions {gfm: true, sanitize: false, smartLists: true, breaks: false}
|
||||||
@docs = _.cloneDeep(@docs)
|
@docs = _.cloneDeep(@docs)
|
||||||
doc.html = marked(doc.i18n?[me.lang()]?.body or doc.body) for doc in @docs
|
doc.html = marked(utils.i18n doc, 'body') for doc in @docs
|
||||||
doc.name = (doc.i18n?[me.lang()]?.name or doc.name) for doc in @docs
|
doc.name = (utils.i18n doc, 'name') for doc in @docs
|
||||||
doc.slug = _.string.slugify(doc.name) for doc in @docs
|
doc.slug = _.string.slugify(doc.name) for doc in @docs
|
||||||
super()
|
super()
|
||||||
|
|
||||||
|
@ -49,4 +50,4 @@ module.exports = class DocsModal extends View
|
||||||
@$el.find('li.active').removeClass('active')
|
@$el.find('li.active').removeClass('active')
|
||||||
|
|
||||||
onHidden: ->
|
onHidden: ->
|
||||||
Backbone.Mediator.publish 'level:docs-hidden'
|
Backbone.Mediator.publish 'level:docs-hidden'
|
||||||
|
|
|
@ -2,8 +2,7 @@ View = require 'views/kinds/ModalView'
|
||||||
template = require 'templates/play/level/modal/victory'
|
template = require 'templates/play/level/modal/victory'
|
||||||
{me} = require 'lib/auth'
|
{me} = require 'lib/auth'
|
||||||
LevelFeedback = require 'models/LevelFeedback'
|
LevelFeedback = require 'models/LevelFeedback'
|
||||||
|
utils = require 'lib/utils'
|
||||||
# let's implement this once we have the docs database schema set up
|
|
||||||
|
|
||||||
module.exports = class VictoryModal extends View
|
module.exports = class VictoryModal extends View
|
||||||
id: 'level-victory-modal'
|
id: 'level-victory-modal'
|
||||||
|
@ -26,7 +25,7 @@ module.exports = class VictoryModal extends View
|
||||||
|
|
||||||
constructor: (options) ->
|
constructor: (options) ->
|
||||||
victory = options.level.get('victory')
|
victory = options.level.get('victory')
|
||||||
body = victory?.i18n?[me.lang()]?.body or victory.body or 'Sorry, this level has no victory message yet.'
|
body = utils.i18n(victory, 'body') or 'Sorry, this level has no victory message yet.'
|
||||||
@body = marked(body)
|
@body = marked(body)
|
||||||
@level = options.level
|
@level = options.level
|
||||||
@session = options.session
|
@session = options.session
|
||||||
|
@ -80,7 +79,7 @@ module.exports = class VictoryModal extends View
|
||||||
c.body = @body
|
c.body = @body
|
||||||
c.me = me
|
c.me = me
|
||||||
c.hasNextLevel = _.isObject(@level.get('nextLevel')) and (@level.get('name') isnt "Mobile Artillery")
|
c.hasNextLevel = _.isObject(@level.get('nextLevel')) and (@level.get('name') isnt "Mobile Artillery")
|
||||||
c.levelName = @level.get('i18n')?[me.lang()]?.name ? @level.get('name')
|
c.levelName = utils.i18n @level.attributes, 'name'
|
||||||
c.level = @level
|
c.level = @level
|
||||||
if c.level.get('type') is 'ladder'
|
if c.level.get('type') is 'ladder'
|
||||||
c1 = @session?.get('code')
|
c1 = @session?.get('code')
|
||||||
|
|
|
@ -27,6 +27,7 @@ module.exports = class SpellPaletteView extends View
|
||||||
c.entryGroups = @entryGroups
|
c.entryGroups = @entryGroups
|
||||||
c.entryGroupSlugs = @entryGroupSlugs
|
c.entryGroupSlugs = @entryGroupSlugs
|
||||||
c.tabbed = _.size(@entryGroups) > 1
|
c.tabbed = _.size(@entryGroups) > 1
|
||||||
|
c.defaultGroupSlug = @defaultGroupSlug
|
||||||
c
|
c
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
|
@ -89,6 +90,7 @@ module.exports = class SpellPaletteView extends View
|
||||||
defaultGroup = $.i18n.t("play_level.tome_available_spells", defaultValue: "Available Spells")
|
defaultGroup = $.i18n.t("play_level.tome_available_spells", defaultValue: "Available Spells")
|
||||||
@entryGroups = {}
|
@entryGroups = {}
|
||||||
@entryGroups[defaultGroup] = @entries
|
@entryGroups[defaultGroup] = @entries
|
||||||
|
@defaultGroupSlug = _.string.slugify defaultGroup
|
||||||
@entryGroupSlugs = {}
|
@entryGroupSlugs = {}
|
||||||
for group, entries of @entryGroups
|
for group, entries of @entryGroups
|
||||||
@entryGroupSlugs[group] = _.string.slugify group
|
@entryGroupSlugs[group] = _.string.slugify group
|
||||||
|
|
|
@ -2,6 +2,7 @@ View = require 'views/kinds/RootView'
|
||||||
template = require 'templates/play/level'
|
template = require 'templates/play/level'
|
||||||
{me} = require('lib/auth')
|
{me} = require('lib/auth')
|
||||||
ThangType = require 'models/ThangType'
|
ThangType = require 'models/ThangType'
|
||||||
|
utils = require 'lib/utils'
|
||||||
|
|
||||||
# temp hard coded data
|
# temp hard coded data
|
||||||
World = require 'lib/world/world'
|
World = require 'lib/world/world'
|
||||||
|
@ -153,7 +154,7 @@ module.exports = class PlayLevelView extends View
|
||||||
if window.currentModal and not window.currentModal.destroyed
|
if window.currentModal and not window.currentModal.destroyed
|
||||||
@loadingScreen.showReady()
|
@loadingScreen.showReady()
|
||||||
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
||||||
|
|
||||||
localStorage["lastLevel"] = @levelID if localStorage?
|
localStorage["lastLevel"] = @levelID if localStorage?
|
||||||
@grabLevelLoaderData()
|
@grabLevelLoaderData()
|
||||||
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
|
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
|
||||||
|
@ -175,7 +176,7 @@ module.exports = class PlayLevelView extends View
|
||||||
if @otherSession
|
if @otherSession
|
||||||
# TODO: colorize name and cloud by team, colorize wizard by user's color config
|
# TODO: colorize name and cloud by team, colorize wizard by user's color config
|
||||||
@surface.createOpponentWizard id: @otherSession.get('creator'), name: @otherSession.get('creatorName'), team: @otherSession.get('team')
|
@surface.createOpponentWizard id: @otherSession.get('creator'), name: @otherSession.get('creatorName'), team: @otherSession.get('team')
|
||||||
|
|
||||||
grabLevelLoaderData: ->
|
grabLevelLoaderData: ->
|
||||||
@session = @levelLoader.session
|
@session = @levelLoader.session
|
||||||
@world = @levelLoader.world
|
@world = @levelLoader.world
|
||||||
|
@ -183,7 +184,7 @@ module.exports = class PlayLevelView extends View
|
||||||
@otherSession = @levelLoader.opponentSession
|
@otherSession = @levelLoader.opponentSession
|
||||||
@levelLoader.destroy()
|
@levelLoader.destroy()
|
||||||
@levelLoader = null
|
@levelLoader = null
|
||||||
|
|
||||||
loadOpponentTeam: (myTeam) ->
|
loadOpponentTeam: (myTeam) ->
|
||||||
opponentSpells = []
|
opponentSpells = []
|
||||||
for spellTeam, spells of @session.get('teamSpells') ? @otherSession?.get('teamSpells') ? {}
|
for spellTeam, spells of @session.get('teamSpells') ? @otherSession?.get('teamSpells') ? {}
|
||||||
|
@ -202,7 +203,7 @@ module.exports = class PlayLevelView extends View
|
||||||
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
|
# For now, ladderGame will disallow multiplayer, because session code combining doesn't play nice yet.
|
||||||
@session.set 'multiplayer', false
|
@session.set 'multiplayer', false
|
||||||
|
|
||||||
|
|
||||||
onSupermodelLoadedOne: =>
|
onSupermodelLoadedOne: =>
|
||||||
@modelsLoaded ?= 0
|
@modelsLoaded ?= 0
|
||||||
@modelsLoaded += 1
|
@modelsLoaded += 1
|
||||||
|
@ -224,7 +225,7 @@ module.exports = class PlayLevelView extends View
|
||||||
@insertSubView new GoldView {}
|
@insertSubView new GoldView {}
|
||||||
@insertSubView new HUDView {}
|
@insertSubView new HUDView {}
|
||||||
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
@insertSubView new ChatView levelID: @levelID, sessionID: @session.id, session: @session
|
||||||
worldName = @level.get('i18n')?[me.lang()]?.name ? @level.get('name')
|
worldName = utils.i18n @level.attributes, 'name'
|
||||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, ladderGame: subviewOptions.ladderGame}
|
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, ladderGame: subviewOptions.ladderGame}
|
||||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ View = require 'views/kinds/RootView'
|
||||||
template = require 'templates/play/spectate'
|
template = require 'templates/play/spectate'
|
||||||
{me} = require('lib/auth')
|
{me} = require('lib/auth')
|
||||||
ThangType = require 'models/ThangType'
|
ThangType = require 'models/ThangType'
|
||||||
|
utils = require 'lib/utils'
|
||||||
|
|
||||||
# temp hard coded data
|
|
||||||
World = require 'lib/world/world'
|
World = require 'lib/world/world'
|
||||||
|
|
||||||
# tools
|
# tools
|
||||||
|
@ -87,8 +87,8 @@ module.exports = class SpectateLevelView extends View
|
||||||
@load()
|
@load()
|
||||||
|
|
||||||
load: ->
|
load: ->
|
||||||
@levelLoader = new LevelLoader
|
@levelLoader = new LevelLoader
|
||||||
supermodel: @supermodel
|
supermodel: @supermodel
|
||||||
levelID: @levelID
|
levelID: @levelID
|
||||||
sessionID: @sessionOne
|
sessionID: @sessionOne
|
||||||
opponentSessionID: @sessionTwo
|
opponentSessionID: @sessionTwo
|
||||||
|
@ -154,17 +154,17 @@ module.exports = class SpectateLevelView extends View
|
||||||
@register()
|
@register()
|
||||||
@controlBar.setBus(@bus)
|
@controlBar.setBus(@bus)
|
||||||
@surface.showLevel()
|
@surface.showLevel()
|
||||||
if me.id isnt @session.get 'creator'
|
if me.id isnt @session.get 'creator'
|
||||||
@surface.createOpponentWizard
|
@surface.createOpponentWizard
|
||||||
id: @session.get('creator')
|
id: @session.get('creator')
|
||||||
name: @session.get('creatorName')
|
name: @session.get('creatorName')
|
||||||
team: @session.get('team')
|
team: @session.get('team')
|
||||||
|
|
||||||
@surface.createOpponentWizard
|
@surface.createOpponentWizard
|
||||||
id: @otherSession.get('creator')
|
id: @otherSession.get('creator')
|
||||||
name: @otherSession.get('creatorName')
|
name: @otherSession.get('creatorName')
|
||||||
team: @otherSession.get('team')
|
team: @otherSession.get('team')
|
||||||
|
|
||||||
|
|
||||||
grabLevelLoaderData: ->
|
grabLevelLoaderData: ->
|
||||||
@session = @levelLoader.session
|
@session = @levelLoader.session
|
||||||
|
@ -213,7 +213,7 @@ module.exports = class SpectateLevelView extends View
|
||||||
|
|
||||||
@insertSubView new GoldView {}
|
@insertSubView new GoldView {}
|
||||||
@insertSubView new HUDView {}
|
@insertSubView new HUDView {}
|
||||||
worldName = @level.get('i18n')?[me.lang()]?.name ? @level.get('name')
|
worldName = utils.i18n @level.attributes, 'name'
|
||||||
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, spectateGame: true}
|
@controlBar = @insertSubView new ControlBarView {worldName: worldName, session: @session, level: @level, supermodel: @supermodel, playableTeams: @world.playableTeams, spectateGame: true}
|
||||||
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
#Backbone.Mediator.publish('level-set-debug', debug: true) if me.displayName() is 'Nick!'
|
||||||
|
|
||||||
|
@ -423,7 +423,7 @@ module.exports = class SpectateLevelView extends View
|
||||||
continue unless thangType = _.find thangTypes, (m) -> m.get('name') is spriteName
|
continue unless thangType = _.find thangTypes, (m) -> m.get('name') is spriteName
|
||||||
continue unless sound = AudioPlayer.soundForDialogue message, thangType.get('soundTriggers')
|
continue unless sound = AudioPlayer.soundForDialogue message, thangType.get('soundTriggers')
|
||||||
AudioPlayer.preloadSoundReference sound
|
AudioPlayer.preloadSoundReference sound
|
||||||
|
|
||||||
onNextGamePressed: (e) ->
|
onNextGamePressed: (e) ->
|
||||||
console.log "You want to see the next game!"
|
console.log "You want to see the next game!"
|
||||||
@sessionOne = "53193c8f7a89df21c4d968e9"
|
@sessionOne = "53193c8f7a89df21c4d968e9"
|
||||||
|
|
Loading…
Reference in a new issue