mirror of
https://github.com/discourse/discourse.git
synced 2025-03-24 11:35:46 +08:00
Fix broken qunit tests in 1.9.0
This commit is contained in:
parent
bdc075b266
commit
7aaf2fcb65
@ -0,0 +1,4 @@
|
||||
Ember.Handlebars.registerBoundHelper("boundI18n", function(property, options) {
|
||||
return new Handlebars.SafeString(I18n.t(property, options.hash));
|
||||
});
|
||||
|
17
app/assets/javascripts/discourse/helpers/count-i18n.js.es6
Normal file
17
app/assets/javascripts/discourse/helpers/count-i18n.js.es6
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
Set up an i18n binding that will update as a count changes, complete with pluralization.
|
||||
|
||||
@method countI18n
|
||||
@for Handlebars
|
||||
**/
|
||||
Ember.Handlebars.registerHelper('countI18n', function(key, options) {
|
||||
var view = Discourse.View.extend(Discourse.StringBuffer, {
|
||||
tagName: 'span',
|
||||
rerenderTriggers: ['count', 'suffix'],
|
||||
|
||||
renderString: function(buffer) {
|
||||
buffer.push(I18n.t(key + (this.get('suffix') || ''), { count: this.get('count') }));
|
||||
}
|
||||
});
|
||||
return Ember.Handlebars.helpers.view.call(this, view, options);
|
||||
});
|
5
app/assets/javascripts/discourse/helpers/i18n.js.es6
Normal file
5
app/assets/javascripts/discourse/helpers/i18n.js.es6
Normal file
@ -0,0 +1,5 @@
|
||||
import registerUnbound from 'discourse/helpers/register-unbound';
|
||||
|
||||
registerUnbound('i18n', function(key, params) {
|
||||
return I18n.t(key, params);
|
||||
});
|
@ -1,56 +0,0 @@
|
||||
// TODO: Remove me when ES6ified
|
||||
var registerUnbound = require('discourse/helpers/register-unbound', null, null, true).default;
|
||||
|
||||
/**
|
||||
We always prefix with "js." to select exactly what we want passed
|
||||
through to the front end.
|
||||
**/
|
||||
var oldI18nlookup = I18n.lookup;
|
||||
I18n.lookup = function(scope, options) {
|
||||
return oldI18nlookup.apply(this, ["js." + scope, options]);
|
||||
};
|
||||
|
||||
/**
|
||||
Default format for storage units
|
||||
**/
|
||||
var oldI18ntoHumanSize = I18n.toHumanSize;
|
||||
I18n.toHumanSize = function(number, options) {
|
||||
options = options || {};
|
||||
options.format = I18n.t("number.human.storage_units.format");
|
||||
return oldI18ntoHumanSize.apply(this, [number, options]);
|
||||
};
|
||||
|
||||
registerUnbound('i18n', function(key, params) {
|
||||
return I18n.t(key, params);
|
||||
});
|
||||
|
||||
/**
|
||||
Bound version of i18n helper.
|
||||
**/
|
||||
Ember.Handlebars.registerBoundHelper("boundI18n", function(property, options) {
|
||||
return new Handlebars.SafeString(I18n.t(property, options.hash));
|
||||
});
|
||||
|
||||
/**
|
||||
Set up an i18n binding that will update as a count changes, complete with pluralization.
|
||||
|
||||
@method countI18n
|
||||
@for Handlebars
|
||||
**/
|
||||
Ember.Handlebars.registerHelper('countI18n', function(key, options) {
|
||||
var view = Discourse.View.extend(Discourse.StringBuffer, {
|
||||
tagName: 'span',
|
||||
rerenderTriggers: ['count', 'suffix'],
|
||||
|
||||
renderString: function(buffer) {
|
||||
buffer.push(I18n.t(key + (this.get('suffix') || ''), { count: this.get('count') }));
|
||||
}
|
||||
});
|
||||
return Ember.Handlebars.helpers.view.call(this, view, options);
|
||||
});
|
||||
|
||||
if (Ember.EXTEND_PROTOTYPES) {
|
||||
String.prototype.i18n = function(options) {
|
||||
return I18n.t(String(this), options);
|
||||
};
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
export default {
|
||||
name: 'default-i18n',
|
||||
|
||||
initialize: function() {
|
||||
// We always prefix with "js." to select exactly what we want passed
|
||||
// through to the front end.
|
||||
var oldI18nlookup = I18n.lookup;
|
||||
I18n.lookup = function(scope, options) {
|
||||
return oldI18nlookup.apply(this, ["js." + scope, options]);
|
||||
};
|
||||
|
||||
// Default format for storage units
|
||||
var oldI18ntoHumanSize = I18n.toHumanSize;
|
||||
I18n.toHumanSize = function(number, options) {
|
||||
options = options || {};
|
||||
options.format = I18n.t("number.human.storage_units.format");
|
||||
return oldI18ntoHumanSize.apply(this, [number, options]);
|
||||
};
|
||||
|
||||
if (Ember.EXTEND_PROTOTYPES) {
|
||||
String.prototype.i18n = function(options) {
|
||||
return I18n.t(String(this), options);
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
};
|
@ -12,7 +12,6 @@
|
||||
// Stuff we need to load first
|
||||
//= require ./discourse/lib/ember_compat_handlebars
|
||||
//= require ./discourse/helpers/register-unbound
|
||||
//= require ./discourse/helpers/i18n_helpers
|
||||
//= require ./discourse/lib/computed
|
||||
//= require ./discourse/mixins/scrolling
|
||||
//= require_tree ./discourse/mixins
|
||||
|
@ -20,7 +20,6 @@
|
||||
//= require pretender
|
||||
|
||||
//= require ../../app/assets/javascripts/locales/i18n
|
||||
//= require ../../app/assets/javascripts/discourse/helpers/i18n_helpers
|
||||
//= require ../../app/assets/javascripts/locales/en
|
||||
|
||||
// Pagedown customizations
|
||||
|
Loading…
x
Reference in New Issue
Block a user