mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-23 23:58:02 -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'
|
||||
{me} = require 'lib/auth'
|
||||
util = require 'lib/utils'
|
||||
utils = require 'lib/utils'
|
||||
|
||||
module.exports = class SpritesScriptModule extends ScriptModule
|
||||
@neededFor: (noteGroup) ->
|
||||
|
@ -36,9 +36,9 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
|||
responses = sprite.say.responses
|
||||
responses = [] unless script.skippable or responses
|
||||
for response in responses ? []
|
||||
response.text = response.i18n?[me.lang()]?.text ? response.text
|
||||
text = util.i18n(sprite.say, 'text')
|
||||
blurb = util.i18n(sprite.say, 'blurb')
|
||||
response.text = utils.i18n response, 'text'
|
||||
text = utils.i18n sprite.say, 'text'
|
||||
blurb = utils.i18n sprite.say, 'blurb'
|
||||
sound = sprite.say.sound # TODO support sound i18n
|
||||
note =
|
||||
channel: 'level-sprite-dialogue'
|
||||
|
|
|
@ -66,5 +66,4 @@ module.exports.i18n = (say, target, language=me.lang(), fallback='en') ->
|
|||
return fallforwardResult if fallforwardResult?
|
||||
return fallbackResult if fallbackResult?
|
||||
return say[target] if target of say
|
||||
return say.text if 'text' of say
|
||||
null
|
||||
|
|
|
@ -6,5 +6,5 @@ ul(class="nav nav-pills" + (tabbed ? ' multiple-tabs' : ''))
|
|||
h4= group
|
||||
.tab-content
|
||||
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)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
View = require 'views/kinds/CocoView'
|
||||
template = require 'templates/play/level/goals'
|
||||
{me} = require 'lib/auth'
|
||||
utils = require 'lib/utils'
|
||||
|
||||
stateIconMap =
|
||||
incomplete: 'icon-minus'
|
||||
|
@ -31,7 +32,7 @@ module.exports = class GoalsView extends View
|
|||
state = e.goalStates[goal.id]
|
||||
continue if goal.hiddenGoal and state.status isnt 'failure'
|
||||
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
|
||||
dead = _.filter(_.values(state.killed)).length
|
||||
targeted = _.values(state.killed).length
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
View = require 'views/kinds/ModalView'
|
||||
template = require 'templates/play/level/modal/docs'
|
||||
Article = require 'models/Article'
|
||||
utils = require 'lib/utils'
|
||||
|
||||
# let's implement this once we have the docs database schema set up
|
||||
|
||||
module.exports = class DocsModal extends View
|
||||
template: template
|
||||
id: 'docs-modal'
|
||||
|
||||
|
||||
shortcuts:
|
||||
'enter': 'hide'
|
||||
|
||||
|
@ -25,8 +26,8 @@ module.exports = class DocsModal extends View
|
|||
@docs = specific.concat(general)
|
||||
marked.setOptions {gfm: true, sanitize: false, smartLists: true, breaks: false}
|
||||
@docs = _.cloneDeep(@docs)
|
||||
doc.html = marked(doc.i18n?[me.lang()]?.body or doc.body) for doc in @docs
|
||||
doc.name = (doc.i18n?[me.lang()]?.name or doc.name) for doc in @docs
|
||||
doc.html = marked(utils.i18n doc, 'body') for doc in @docs
|
||||
doc.name = (utils.i18n doc, 'name') for doc in @docs
|
||||
doc.slug = _.string.slugify(doc.name) for doc in @docs
|
||||
super()
|
||||
|
||||
|
@ -49,4 +50,4 @@ module.exports = class DocsModal extends View
|
|||
@$el.find('li.active').removeClass('active')
|
||||
|
||||
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'
|
||||
{me} = require 'lib/auth'
|
||||
LevelFeedback = require 'models/LevelFeedback'
|
||||
|
||||
# let's implement this once we have the docs database schema set up
|
||||
utils = require 'lib/utils'
|
||||
|
||||
module.exports = class VictoryModal extends View
|
||||
id: 'level-victory-modal'
|
||||
|
@ -26,7 +25,7 @@ module.exports = class VictoryModal extends View
|
|||
|
||||
constructor: (options) ->
|
||||
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)
|
||||
@level = options.level
|
||||
@session = options.session
|
||||
|
@ -80,7 +79,7 @@ module.exports = class VictoryModal extends View
|
|||
c.body = @body
|
||||
c.me = me
|
||||
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
|
||||
if c.level.get('type') is 'ladder'
|
||||
c1 = @session?.get('code')
|
||||
|
|
|
@ -27,6 +27,7 @@ module.exports = class SpellPaletteView extends View
|
|||
c.entryGroups = @entryGroups
|
||||
c.entryGroupSlugs = @entryGroupSlugs
|
||||
c.tabbed = _.size(@entryGroups) > 1
|
||||
c.defaultGroupSlug = @defaultGroupSlug
|
||||
c
|
||||
|
||||
afterRender: ->
|
||||
|
@ -89,6 +90,7 @@ module.exports = class SpellPaletteView extends View
|
|||
defaultGroup = $.i18n.t("play_level.tome_available_spells", defaultValue: "Available Spells")
|
||||
@entryGroups = {}
|
||||
@entryGroups[defaultGroup] = @entries
|
||||
@defaultGroupSlug = _.string.slugify defaultGroup
|
||||
@entryGroupSlugs = {}
|
||||
for group, entries of @entryGroups
|
||||
@entryGroupSlugs[group] = _.string.slugify group
|
||||
|
|
|
@ -2,6 +2,7 @@ View = require 'views/kinds/RootView'
|
|||
template = require 'templates/play/level'
|
||||
{me} = require('lib/auth')
|
||||
ThangType = require 'models/ThangType'
|
||||
utils = require 'lib/utils'
|
||||
|
||||
# temp hard coded data
|
||||
World = require 'lib/world/world'
|
||||
|
@ -153,7 +154,7 @@ module.exports = class PlayLevelView extends View
|
|||
if window.currentModal and not window.currentModal.destroyed
|
||||
@loadingScreen.showReady()
|
||||
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
||||
|
||||
|
||||
localStorage["lastLevel"] = @levelID if localStorage?
|
||||
@grabLevelLoaderData()
|
||||
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
|
||||
|
@ -175,7 +176,7 @@ module.exports = class PlayLevelView extends View
|
|||
if @otherSession
|
||||
# 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')
|
||||
|
||||
|
||||
grabLevelLoaderData: ->
|
||||
@session = @levelLoader.session
|
||||
@world = @levelLoader.world
|
||||
|
@ -183,7 +184,7 @@ module.exports = class PlayLevelView extends View
|
|||
@otherSession = @levelLoader.opponentSession
|
||||
@levelLoader.destroy()
|
||||
@levelLoader = null
|
||||
|
||||
|
||||
loadOpponentTeam: (myTeam) ->
|
||||
opponentSpells = []
|
||||
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.
|
||||
@session.set 'multiplayer', false
|
||||
|
||||
|
||||
|
||||
onSupermodelLoadedOne: =>
|
||||
@modelsLoaded ?= 0
|
||||
@modelsLoaded += 1
|
||||
|
@ -224,7 +225,7 @@ module.exports = class PlayLevelView extends View
|
|||
@insertSubView new GoldView {}
|
||||
@insertSubView new HUDView {}
|
||||
@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}
|
||||
#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'
|
||||
{me} = require('lib/auth')
|
||||
ThangType = require 'models/ThangType'
|
||||
utils = require 'lib/utils'
|
||||
|
||||
# temp hard coded data
|
||||
World = require 'lib/world/world'
|
||||
|
||||
# tools
|
||||
|
@ -87,8 +87,8 @@ module.exports = class SpectateLevelView extends View
|
|||
@load()
|
||||
|
||||
load: ->
|
||||
@levelLoader = new LevelLoader
|
||||
supermodel: @supermodel
|
||||
@levelLoader = new LevelLoader
|
||||
supermodel: @supermodel
|
||||
levelID: @levelID
|
||||
sessionID: @sessionOne
|
||||
opponentSessionID: @sessionTwo
|
||||
|
@ -154,17 +154,17 @@ module.exports = class SpectateLevelView extends View
|
|||
@register()
|
||||
@controlBar.setBus(@bus)
|
||||
@surface.showLevel()
|
||||
if me.id isnt @session.get 'creator'
|
||||
if me.id isnt @session.get 'creator'
|
||||
@surface.createOpponentWizard
|
||||
id: @session.get('creator')
|
||||
name: @session.get('creatorName')
|
||||
team: @session.get('team')
|
||||
|
||||
@surface.createOpponentWizard
|
||||
|
||||
@surface.createOpponentWizard
|
||||
id: @otherSession.get('creator')
|
||||
name: @otherSession.get('creatorName')
|
||||
team: @otherSession.get('team')
|
||||
|
||||
|
||||
|
||||
grabLevelLoaderData: ->
|
||||
@session = @levelLoader.session
|
||||
|
@ -213,7 +213,7 @@ module.exports = class SpectateLevelView extends View
|
|||
|
||||
@insertSubView new GoldView {}
|
||||
@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}
|
||||
#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 sound = AudioPlayer.soundForDialogue message, thangType.get('soundTriggers')
|
||||
AudioPlayer.preloadSoundReference sound
|
||||
|
||||
|
||||
onNextGamePressed: (e) ->
|
||||
console.log "You want to see the next game!"
|
||||
@sessionOne = "53193c8f7a89df21c4d968e9"
|
||||
|
|
Loading…
Reference in a new issue