mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 08:09:31 +08:00
Run prettier on a couple of files
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// ensure Discourse is added as a global
|
||||
(function() {
|
||||
window.Discourse = requirejs('discourse').default;
|
||||
window.Discourse = requirejs("discourse").default;
|
||||
})();
|
||||
|
@ -111,9 +111,11 @@ I18n.interpolate = function(message, options) {
|
||||
value,
|
||||
name;
|
||||
|
||||
if (!matches) { return message; }
|
||||
if (!matches) {
|
||||
return message;
|
||||
}
|
||||
|
||||
for (var i = 0; placeholder = matches[i]; i++) {
|
||||
for (var i = 0; (placeholder = matches[i]); i++) {
|
||||
name = placeholder.replace(this.PLACEHOLDER, "$1");
|
||||
|
||||
if (typeof options[name] === "string") {
|
||||
@ -130,7 +132,9 @@ I18n.interpolate = function(message, options) {
|
||||
value = "[missing " + placeholder + " value]";
|
||||
}
|
||||
|
||||
var regex = new RegExp(placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}"));
|
||||
var regex = new RegExp(
|
||||
placeholder.replace(/\{/gm, "\\{").replace(/\}/gm, "\\}")
|
||||
);
|
||||
message = message.replace(regex, value);
|
||||
}
|
||||
|
||||
@ -157,8 +161,8 @@ I18n.translate = function(scope, options) {
|
||||
translation = this.findTranslation(scope, options);
|
||||
}
|
||||
|
||||
if (!translation && this.currentLocale() !== 'en') {
|
||||
options.locale = 'en';
|
||||
if (!translation && this.currentLocale() !== "en") {
|
||||
options.locale = "en";
|
||||
translation = this.findTranslation(scope, options);
|
||||
}
|
||||
}
|
||||
@ -181,14 +185,17 @@ I18n.findTranslation = function(scope, options) {
|
||||
};
|
||||
|
||||
I18n.toNumber = function(number, options) {
|
||||
options = this.prepareOptions(
|
||||
options,
|
||||
this.lookup("number.format"),
|
||||
{precision: 3, separator: this.SEPARATOR, delimiter: ",", strip_insignificant_zeros: false}
|
||||
);
|
||||
options = this.prepareOptions(options, this.lookup("number.format"), {
|
||||
precision: 3,
|
||||
separator: this.SEPARATOR,
|
||||
delimiter: ",",
|
||||
strip_insignificant_zeros: false
|
||||
});
|
||||
|
||||
var negative = number < 0,
|
||||
string = Math.abs(number).toFixed(options.precision).toString(),
|
||||
string = Math.abs(number)
|
||||
.toFixed(options.precision)
|
||||
.toString(),
|
||||
parts = string.split(this.SEPARATOR),
|
||||
precision,
|
||||
buffer = [],
|
||||
@ -220,8 +227,7 @@ I18n.toNumber = function(number, options) {
|
||||
|
||||
formattedNumber = formattedNumber
|
||||
.replace(regex.zeros, "")
|
||||
.replace(regex.separator, "")
|
||||
;
|
||||
.replace(regex.separator, "");
|
||||
}
|
||||
|
||||
return formattedNumber;
|
||||
@ -243,20 +249,21 @@ I18n.toHumanSize = function(number, options) {
|
||||
unit = this.t("number.human.storage_units.units.byte", { count: size });
|
||||
precision = 0;
|
||||
} else {
|
||||
unit = this.t("number.human.storage_units.units." + [null, "kb", "mb", "gb", "tb"][iterations]);
|
||||
precision = (size - Math.floor(size) === 0) ? 0 : 1;
|
||||
unit = this.t(
|
||||
"number.human.storage_units.units." +
|
||||
[null, "kb", "mb", "gb", "tb"][iterations]
|
||||
);
|
||||
precision = size - Math.floor(size) === 0 ? 0 : 1;
|
||||
}
|
||||
|
||||
options = this.prepareOptions(
|
||||
options,
|
||||
{precision: precision, format: "%n%u", delimiter: ""}
|
||||
);
|
||||
options = this.prepareOptions(options, {
|
||||
precision: precision,
|
||||
format: "%n%u",
|
||||
delimiter: ""
|
||||
});
|
||||
|
||||
number = this.toNumber(size, options);
|
||||
number = options.format
|
||||
.replace("%u", unit)
|
||||
.replace("%n", number)
|
||||
;
|
||||
number = options.format.replace("%u", unit).replace("%n", number);
|
||||
|
||||
return number;
|
||||
};
|
||||
@ -283,7 +290,7 @@ I18n.pluralize = function(translation, scope, options) {
|
||||
|
||||
var pluralizer = this.pluralizer(options.locale || this.currentLocale());
|
||||
var key = pluralizer(Math.abs(count));
|
||||
var keys = ((typeof key === "object") && (key instanceof Array)) ? key : [key];
|
||||
var keys = typeof key === "object" && key instanceof Array ? key : [key];
|
||||
|
||||
var message = this.findAndTranslateValidNode(keys, translation);
|
||||
|
||||
@ -295,9 +302,11 @@ I18n.pluralize = function(translation, scope, options) {
|
||||
};
|
||||
|
||||
I18n.missingTranslation = function(scope, key) {
|
||||
var message = '[' + this.currentLocale() + this.SEPARATOR + scope;
|
||||
if (key) { message += this.SEPARATOR + key; }
|
||||
return message + ']';
|
||||
var message = "[" + this.currentLocale() + this.SEPARATOR + scope;
|
||||
if (key) {
|
||||
message += this.SEPARATOR + key;
|
||||
}
|
||||
return message + "]";
|
||||
};
|
||||
|
||||
I18n.currentLocale = function() {
|
||||
@ -330,7 +339,7 @@ I18n.enableVerboseLocalizationSession = function() {
|
||||
sessionStorage.setItem("verbose_localization", "true");
|
||||
I18n.enableVerboseLocalization();
|
||||
|
||||
return 'Verbose localization is enabled. Close the browser tab to turn it off. Reload the page to see the translation keys.';
|
||||
return "Verbose localization is enabled. Close the browser tab to turn it off. Reload the page to see the translation keys.";
|
||||
};
|
||||
|
||||
// shortcuts
|
||||
|
Reference in New Issue
Block a user