From 342b883c73c08227fec95484c01b84c19cc0b626 Mon Sep 17 00:00:00 2001 From: Zog Date: Mon, 14 May 2018 11:41:52 +0200 Subject: Refs #6998: Fix JS specs --- spec/javascript/support/i18n-extended.js | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 spec/javascript/support/i18n-extended.js (limited to 'spec/javascript/support/i18n-extended.js') diff --git a/spec/javascript/support/i18n-extended.js b/spec/javascript/support/i18n-extended.js new file mode 100644 index 000000000..900667b62 --- /dev/null +++ b/spec/javascript/support/i18n-extended.js @@ -0,0 +1,36 @@ +(function() { + //= require i18n + var decorateI18n; + + decorateI18n = function(_i18n) { + _i18n.tc = function(key, opts = {}) { + var out; + out = _i18n.t(key, opts); + if (_i18n.locale === "fr") { + out += " "; + } + return out + ":"; + }; + _i18n.model_name = function(model, opts = {}) { + var last_key; + last_key = opts.plural ? "other" : "one"; + return _i18n.t(`activerecord.models.${model}.${last_key}`); + }; + _i18n.attribute_name = function(model, attribute, opts = {}) { + return _i18n.t(`activerecord.attributes.${model}.${attribute}`); + }; + _i18n.enumerize = function(enumerize, key, opts = {}) { + return I18n.t(`enumerize.${enumerize}.${key}`); + }; + return _i18n; + }; + + if (typeof module !== "undefined" && module !== null) { + module.exports = decorateI18n; + } + + if (typeof I18n !== "undefined" && I18n !== null) { + decorateI18n(I18n); + } + +}).call(this); -- cgit v1.2.3