mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-05-03 09:23:41 -04:00
Added the finishing touch. Solved issue #15
This commit is contained in:
parent
3856ac597f
commit
96ec29d80e
3 changed files with 8 additions and 3 deletions
|
@ -1,5 +1,6 @@
|
||||||
ScriptModule = require './ScriptModule'
|
ScriptModule = require './ScriptModule'
|
||||||
{me} = require 'lib/auth'
|
{me} = require 'lib/auth'
|
||||||
|
util = require 'lib/utils'
|
||||||
|
|
||||||
module.exports = class SpritesScriptModule extends ScriptModule
|
module.exports = class SpritesScriptModule extends ScriptModule
|
||||||
@neededFor: (noteGroup) ->
|
@neededFor: (noteGroup) ->
|
||||||
|
@ -36,9 +37,9 @@ module.exports = class SpritesScriptModule extends ScriptModule
|
||||||
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 = response.i18n?[me.lang()]?.text ? response.text
|
||||||
text = sprite.say.i18n?[me.lang()]?.text or sprite.say.text
|
text = util.i18n(sprite.say, 'text')
|
||||||
blurb = sprite.say.i18n?[me.lang()]?.blurb or sprite.say.blurb
|
blurb = util.i18n(sprite.say, 'blurb')
|
||||||
sound = sprite.say.sound?[me.lang()]?.sound or sprite.say.sound
|
sound = sprite.say.sound # TODO support sound i18n
|
||||||
note =
|
note =
|
||||||
channel: 'level-sprite-dialogue'
|
channel: 'level-sprite-dialogue'
|
||||||
event:
|
event:
|
||||||
|
|
|
@ -65,5 +65,6 @@ module.exports.i18n = (say, target, language=me.lang(), fallback='en') ->
|
||||||
return generalResult if generalResult?
|
return generalResult if generalResult?
|
||||||
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.text if 'text' of say
|
return say.text if 'text' of say
|
||||||
null
|
null
|
|
@ -4,6 +4,7 @@ describe 'utils library', ->
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
this.fixture1 =
|
this.fixture1 =
|
||||||
"text": "G'day, Wizard! Come to practice? Well, let's get started..."
|
"text": "G'day, Wizard! Come to practice? Well, let's get started..."
|
||||||
|
"blurb": "G'day"
|
||||||
"i18n":
|
"i18n":
|
||||||
"es-419":
|
"es-419":
|
||||||
"text": "¡Buenas, Hechicero! ¿Vienes a practicar? Bueno, empecemos..."
|
"text": "¡Buenas, Hechicero! ¿Vienes a practicar? Bueno, empecemos..."
|
||||||
|
@ -37,6 +38,8 @@ describe 'utils library', ->
|
||||||
it 'i18n falls back to the default text, even for other targets (like blurb)', ->
|
it 'i18n falls back to the default text, even for other targets (like blurb)', ->
|
||||||
delete this.fixture1.i18n['en']
|
delete this.fixture1.i18n['en']
|
||||||
expect(util.i18n(this.fixture1, 'text', 'en')).toEqual(this.fixture1.text)
|
expect(util.i18n(this.fixture1, 'text', 'en')).toEqual(this.fixture1.text)
|
||||||
|
expect(util.i18n(this.fixture1, 'blurb', 'en')).toEqual(this.fixture1.blurb)
|
||||||
|
delete this.fixture1.blurb
|
||||||
expect(util.i18n(this.fixture1, 'blurb', 'en')).toEqual(this.fixture1.text)
|
expect(util.i18n(this.fixture1, 'blurb', 'en')).toEqual(this.fixture1.text)
|
||||||
|
|
||||||
it 'i18n can fall forward if a general language is not found', ->
|
it 'i18n can fall forward if a general language is not found', ->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue