codecombat/codecombat — pull request #532 by rubenvereecken (2014-03-13 00:16:07+00:00)
Title: Added i18n function, fixed issue #15

Added a utility function in lib/utils, named 'i18n'. The signature is quite simple:
``i18n = (say, target, language=me.lang(), fallback='en')``

This now gets used twice in the existing code, like so:
``text = util.i18n(sprite.say, 'text')``

Advantages, as per issue #15:
- Falls back from specific to general locale, e.g. 'es-ES' -> 'es'
- Falls back to a default language or, if not available, a target object (like _blurb_) or if not available, a _text_ object
- Falls forward to a more specific locale if the general would not be available for some reason, e.g. 'es' -> 'es-ES'

Because loading a game takes too long to actually test something decently I wrote some Jasmine tests in test/app/utils.spec.coffee. All pass.