Fix badge description i18n match.

This commit is contained in:
Vikhyat Korrapati 2014-03-17 18:43:09 +05:30
parent 9b26c8584e
commit 4f71256542
2 changed files with 2 additions and 2 deletions

View File

@ -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;

View File

@ -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");
});