Merge pull request #2137 from vikhyat/badge-system

Fix badge description i18n match
This commit is contained in:
Régis Hanol 2014-03-17 14:57:03 +01:00
commit 26578d1b73
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");
});