Merge pull request #2137 from vikhyat/badge-system
Fix badge description i18n match
This commit is contained in:
commit
26578d1b73
|
@ -48,7 +48,7 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
translatedDescription: function() {
|
translatedDescription: function() {
|
||||||
var i18nKey = "badges." + this.get('i18nNameKey') + ".description",
|
var i18nKey = "badges." + this.get('i18nNameKey') + ".description",
|
||||||
translation = I18n.t(i18nKey);
|
translation = I18n.t(i18nKey);
|
||||||
if (translation.match(new RegExp(i18nKey))) {
|
if (translation.indexOf(i18nKey) !== -1) {
|
||||||
translation = null;
|
translation = null;
|
||||||
}
|
}
|
||||||
return translation;
|
return translation;
|
||||||
|
|
|
@ -20,7 +20,7 @@ test('translatedDescription', function() {
|
||||||
var badge1 = Discourse.Badge.create({id: 1, name: "Test Badge 1"});
|
var badge1 = Discourse.Badge.create({id: 1, name: "Test Badge 1"});
|
||||||
equal(badge1.get('translatedDescription'), null, "returns null when no translation exists");
|
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");
|
this.stub(I18n, "t").returns("description translation");
|
||||||
equal(badge2.get('translatedDescription'), "description translation", "users translated description");
|
equal(badge2.get('translatedDescription'), "description translation", "users translated description");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue