mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-01 07:40:22 -04:00
Reverted work done on wrong branch
This commit is contained in:
parent
6d3525afe6
commit
8c7c49fdbb
2 changed files with 0 additions and 65 deletions
|
@ -45,25 +45,3 @@ toHex = (n) ->
|
|||
h = Math.floor(n).toString(16)
|
||||
h = '0'+h if h.length is 1
|
||||
h
|
||||
|
||||
i18n = (say, target, language=me.lang(), fallback='en') ->
|
||||
generalResult = null
|
||||
fallbackResult = null
|
||||
fallforwardResult = null # If a general language isn't available, the first specific one will do
|
||||
matches = (/\w+/gi).exec(language)
|
||||
generalName = matches[0] if matches
|
||||
|
||||
for locale in say?.i18n
|
||||
if target of say[locale]
|
||||
result = say[locale][target]
|
||||
else continue
|
||||
return result if locale == language
|
||||
generalResult = result if locale == generalName
|
||||
fallbackResult = result if locale == fallback
|
||||
fallforwardResult = result if locale.indexOf language != -1 and not fallforwardResult?
|
||||
|
||||
return generalResult if generalResult?
|
||||
return fallbackResult if fallbackResult?
|
||||
return fallforwardResult if fallforwardResult?
|
||||
return say.text if 'text' of say
|
||||
null
|
|
@ -1,43 +0,0 @@
|
|||
describe 'utils library', ->
|
||||
require 'lib/utils'
|
||||
|
||||
beforeEach ->
|
||||
fixture1 = {
|
||||
"text": "G'day, Wizard! Come to practice? Well, let's get started...",
|
||||
"i18n": {
|
||||
"es-419": {
|
||||
"text": "¡Buenas, Hechicero! ¿Vienes a practicar? Bueno, empecemos..."
|
||||
},
|
||||
"es-ES": {
|
||||
"text": "¡Buenas Mago! ¿Vienes a practicar? Bien, empecemos..."
|
||||
},
|
||||
"es": {
|
||||
"text": "¡Buenas Mago! ¿Vienes a practicar? Muy bien, empecemos..."
|
||||
},
|
||||
"fr": {
|
||||
"text": "S'lut, Magicien! Venu pratiquer? Ok, bien débutons..."
|
||||
},
|
||||
"pt-BR": {
|
||||
"text": "Bom dia, feiticeiro! Veio praticar? Então vamos começar..."
|
||||
},
|
||||
"de": {
|
||||
"text": "'N Tach auch, Zauberer! Kommst Du zum Üben? Dann lass uns anfangen..."
|
||||
},
|
||||
"tr": {
|
||||
"text": "İyi günler, Büyücü! Antremana mı geldin? Güzel, hadi başlayalım..."
|
||||
},
|
||||
"sv": {
|
||||
"text": "Godagens, trollkarl! Kommit för att öva? Nå, låt oss börja..."
|
||||
},
|
||||
"en": {
|
||||
"text": "Ohai Magician!"
|
||||
}
|
||||
},
|
||||
"sound": {
|
||||
"mp3": "db/level/52740644904ac0411700067c/gday_wizard_come_to_practice.mp3",
|
||||
"ogg": "db/level/52740644904ac0411700067c/gday_wizard_come_to_practice.ogg"
|
||||
}
|
||||
}
|
||||
|
||||
it 'i18n should find a valid target string', ->
|
||||
expect(i18n(fixture1, 'text', 'en')).toEqual(fixture1.i18n.en.text)
|
Loading…
Add table
Reference in a new issue