diff --git a/app/lib/utils.coffee b/app/lib/utils.coffee index 29f1434f2..24a59cdb5 100644 --- a/app/lib/utils.coffee +++ b/app/lib/utils.coffee @@ -46,7 +46,7 @@ toHex = (n) -> h = '0'+h if h.length is 1 h -i18n = (say, target, language=me.lang(), fallback='en') -> +module.exports.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 diff --git a/test/app/lib/utils.spec.coffee b/test/app/lib/utils.spec.coffee index d729517a0..8de7a0e5a 100644 --- a/test/app/lib/utils.spec.coffee +++ b/test/app/lib/utils.spec.coffee @@ -1,8 +1,8 @@ describe 'utils library', -> - require 'lib/utils' + util = require 'lib/utils' beforeEach -> - fixture1 = { + this.fixture1 = { "text": "G'day, Wizard! Come to practice? Well, let's get started...", "i18n": { "es-419": { @@ -29,7 +29,7 @@ describe 'utils library', -> "sv": { "text": "Godagens, trollkarl! Kommit för att öva? Nå, låt oss börja..." }, - "en": { + "ex": { "text": "Ohai Magician!" } }, @@ -40,4 +40,4 @@ describe 'utils library', -> } it 'i18n should find a valid target string', -> - expect(i18n(fixture1, 'text', 'en')).toEqual(fixture1.i18n.en.text) + expect(util.i18n(this.fixture1, 'text', 'sv')).toEqual(this.fixture1.i18n.en.text)