From 4f71256542e31975504f09d9d40e3f529bf3f13a Mon Sep 17 00:00:00 2001 From: Vikhyat Korrapati Date: Mon, 17 Mar 2014 18:43:09 +0530 Subject: [PATCH] Fix badge description i18n match. --- app/assets/javascripts/discourse/models/badge.js | 2 +- test/javascripts/models/badge_test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/discourse/models/badge.js b/app/assets/javascripts/discourse/models/badge.js index ee712f60123..0845892eb12 100644 --- a/app/assets/javascripts/discourse/models/badge.js +++ b/app/assets/javascripts/discourse/models/badge.js @@ -48,7 +48,7 @@ Discourse.Badge = Discourse.Model.extend({ translatedDescription: function() { var i18nKey = "badges." + this.get('i18nNameKey') + ".description", translation = I18n.t(i18nKey); - if (translation.match(new RegExp(i18nKey))) { + if (translation.indexOf(i18nKey) !== -1) { translation = null; } return translation; diff --git a/test/javascripts/models/badge_test.js b/test/javascripts/models/badge_test.js index b19f55e296c..dbd1c7549d2 100644 --- a/test/javascripts/models/badge_test.js +++ b/test/javascripts/models/badge_test.js @@ -20,7 +20,7 @@ test('translatedDescription', function() { var badge1 = Discourse.Badge.create({id: 1, name: "Test Badge 1"}); equal(badge1.get('translatedDescription'), null, "returns null when no translation exists"); - var badge2 = Discourse.Badge.create({id: 2, name: "Test Badge 2"}); + var badge2 = Discourse.Badge.create({id: 2, name: "Test Badge 2 **"}); this.stub(I18n, "t").returns("description translation"); equal(badge2.get('translatedDescription'), "description translation", "users translated description"); });