Merge pull request #2346 from vikhyat/badge-system
Fix missing badge descriptions
This commit is contained in:
commit
bad3c6ea49
|
@ -40,7 +40,8 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
}.property('name', 'i18nNameKey'),
|
}.property('name', 'i18nNameKey'),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
The i18n translated description for this badge. `null` if no translation exists.
|
The i18n translated description for this badge. Returns the original
|
||||||
|
description if no translation exists.
|
||||||
|
|
||||||
@property translatedDescription
|
@property translatedDescription
|
||||||
@type {String}
|
@type {String}
|
||||||
|
@ -49,7 +50,7 @@ Discourse.Badge = Discourse.Model.extend({
|
||||||
var i18nKey = "badges.badge." + this.get('i18nNameKey') + ".description",
|
var i18nKey = "badges.badge." + this.get('i18nNameKey') + ".description",
|
||||||
translation = I18n.t(i18nKey);
|
translation = I18n.t(i18nKey);
|
||||||
if (translation.indexOf(i18nKey) !== -1) {
|
if (translation.indexOf(i18nKey) !== -1) {
|
||||||
translation = null;
|
translation = this.get('description');
|
||||||
}
|
}
|
||||||
return translation;
|
return translation;
|
||||||
}.property('i18nNameKey'),
|
}.property('i18nNameKey'),
|
||||||
|
|
|
@ -17,8 +17,8 @@ test('displayName', function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
test('translatedDescription', function() {
|
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", description: "TEST"});
|
||||||
equal(badge1.get('translatedDescription'), null, "returns null when no translation exists");
|
equal(badge1.get('translatedDescription'), "TEST", "returns original description 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");
|
||||||
|
|
Loading…
Reference in New Issue