aboutsummaryrefslogtreecommitdiffstats
path: root/spec/javascript/support/i18n-extended.js
diff options
context:
space:
mode:
authorLuc Donnet2018-05-15 15:29:10 +0200
committerGitHub2018-05-15 15:29:10 +0200
commitfc2aa2640185a081231d2f726bb345e5bd7709a9 (patch)
treebbf8632c24d01faee28a1a209b3e84f0041a275e /spec/javascript/support/i18n-extended.js
parent0ea92f772d7eb8facd7cedd50d50531e25664af5 (diff)
parent342b883c73c08227fec95484c01b84c19cc0b626 (diff)
downloadchouette-core-fc2aa2640185a081231d2f726bb345e5bd7709a9.tar.bz2
Merge pull request #567 from af83/6998-fix-jest-specs
6998 Fix JS specs
Diffstat (limited to 'spec/javascript/support/i18n-extended.js')
-rw-r--r--spec/javascript/support/i18n-extended.js36
1 files changed, 36 insertions, 0 deletions
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);