From 0eed8b45787c841ba70fd737056decd6164b5639 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 1 Oct 2015 14:16:59 +1000 Subject: [PATCH] better testing of existence of I18n --- app/assets/javascripts/darkswarm/i18n.js.coffee | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/darkswarm/i18n.js.coffee b/app/assets/javascripts/darkswarm/i18n.js.coffee index 857437a51d..15ee584400 100644 --- a/app/assets/javascripts/darkswarm/i18n.js.coffee +++ b/app/assets/javascripts/darkswarm/i18n.js.coffee @@ -1,12 +1,13 @@ # Declares the translation function t. # You can use t('login') in Javascript. window.t = (key, options = {}) -> - if I18n == undefined + unless 'I18n' of window console.log 'The I18n object is undefined. Cannot translate text.' return key + return key unless key of I18n text = I18n[key] - return key if text == undefined - text = text.split("%{#{name}}").join(value) for name, value of options + for name, value of options + text = text.split("%{#{name}}").join(value) text # Provides the translation function t on all scopes.