i18n_screwdriver 10.6.0 → 10.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fa9bd2e0ccceead616ebb82ef83705b1a54939608e934306593fd8eebc74aca2
4
- data.tar.gz: 53b47904084de4654d3c075d2a9020dc464d81297aec29dc73ef5429d2621dd5
3
+ metadata.gz: 76a39322176f654caf984b440afbec19e5ab621ec43e12987387abb557eaa39d
4
+ data.tar.gz: ebeb4e4d601f2e2e3b285c0205df1fe4fd431222e320e682602147f7fe480774
5
5
  SHA512:
6
- metadata.gz: ed79659d0e77af3d8fe6cb27271a441170c413dd3146f1fa31b58f8901ae98effaed866927ec509b257dd4e4b035af8c1f6923de428178a28533095eaa71e5a5
7
- data.tar.gz: 569ca1e97f328bb5890504c228063ed68bac1a7cc13c8b3447e175d992e0ac37aeb6beead51436a6c6cae552dd7030a82c9a4475df965cabe6ad909c33bcdfe5
6
+ metadata.gz: fd6d8db420e11c9bfa2b64097d341e3fc35665bb3d65b4f2a174192ab5d49b8df26bc19caf0b4ace16ed18bc6a27666fbbcc07abdbc4a3d258b3dca35a2ba401
7
+ data.tar.gz: af29837b462f81b67c57af11a3e54dd563f4c29096760f11ffdf08dac9140ee8b4bf8e8cf3c5c842ffa88f97a84800bac091c6bdc7b0b120947c5d9be0d6a448
data/.babelrc ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "plugins": [["@babel/plugin-proposal-optional-chaining"]]
3
+ }
data/.gitignore CHANGED
@@ -2,6 +2,7 @@
2
2
  .bundle
3
3
  Gemfile.lock
4
4
  pkg/*
5
+ node_modules/
5
6
 
6
7
  .idea
7
8
 
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.6.1
1
+ 2.7.4
data/Gemfile.lock CHANGED
@@ -1,134 +1,153 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n_screwdriver (10.6.0)
4
+ i18n_screwdriver (10.7.0)
5
5
  rails (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- actioncable (5.2.2)
11
- actionpack (= 5.2.2)
10
+ actioncable (6.1.4.1)
11
+ actionpack (= 6.1.4.1)
12
+ activesupport (= 6.1.4.1)
12
13
  nio4r (~> 2.0)
13
14
  websocket-driver (>= 0.6.1)
14
- actionmailer (5.2.2)
15
- actionpack (= 5.2.2)
16
- actionview (= 5.2.2)
17
- activejob (= 5.2.2)
15
+ actionmailbox (6.1.4.1)
16
+ actionpack (= 6.1.4.1)
17
+ activejob (= 6.1.4.1)
18
+ activerecord (= 6.1.4.1)
19
+ activestorage (= 6.1.4.1)
20
+ activesupport (= 6.1.4.1)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.4.1)
23
+ actionpack (= 6.1.4.1)
24
+ actionview (= 6.1.4.1)
25
+ activejob (= 6.1.4.1)
26
+ activesupport (= 6.1.4.1)
18
27
  mail (~> 2.5, >= 2.5.4)
19
28
  rails-dom-testing (~> 2.0)
20
- actionpack (5.2.2)
21
- actionview (= 5.2.2)
22
- activesupport (= 5.2.2)
23
- rack (~> 2.0)
29
+ actionpack (6.1.4.1)
30
+ actionview (= 6.1.4.1)
31
+ activesupport (= 6.1.4.1)
32
+ rack (~> 2.0, >= 2.0.9)
24
33
  rack-test (>= 0.6.3)
25
34
  rails-dom-testing (~> 2.0)
26
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
- actionview (5.2.2)
28
- activesupport (= 5.2.2)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.4.1)
37
+ actionpack (= 6.1.4.1)
38
+ activerecord (= 6.1.4.1)
39
+ activestorage (= 6.1.4.1)
40
+ activesupport (= 6.1.4.1)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.4.1)
43
+ activesupport (= 6.1.4.1)
29
44
  builder (~> 3.1)
30
45
  erubi (~> 1.4)
31
46
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
- activejob (5.2.2)
34
- activesupport (= 5.2.2)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.4.1)
49
+ activesupport (= 6.1.4.1)
35
50
  globalid (>= 0.3.6)
36
- activemodel (5.2.2)
37
- activesupport (= 5.2.2)
38
- activerecord (5.2.2)
39
- activemodel (= 5.2.2)
40
- activesupport (= 5.2.2)
41
- arel (>= 9.0)
42
- activestorage (5.2.2)
43
- actionpack (= 5.2.2)
44
- activerecord (= 5.2.2)
45
- marcel (~> 0.3.1)
46
- activesupport (5.2.2)
51
+ activemodel (6.1.4.1)
52
+ activesupport (= 6.1.4.1)
53
+ activerecord (6.1.4.1)
54
+ activemodel (= 6.1.4.1)
55
+ activesupport (= 6.1.4.1)
56
+ activestorage (6.1.4.1)
57
+ actionpack (= 6.1.4.1)
58
+ activejob (= 6.1.4.1)
59
+ activerecord (= 6.1.4.1)
60
+ activesupport (= 6.1.4.1)
61
+ marcel (~> 1.0.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.4.1)
47
64
  concurrent-ruby (~> 1.0, >= 1.0.2)
48
- i18n (>= 0.7, < 2)
49
- minitest (~> 5.1)
50
- tzinfo (~> 1.1)
51
- arel (9.0.0)
52
- builder (3.2.3)
53
- byebug (9.0.6)
54
- concurrent-ruby (1.1.4)
55
- crass (1.0.5)
56
- diff-lcs (1.2.5)
57
- erubi (1.8.0)
58
- globalid (0.4.2)
59
- activesupport (>= 4.2.0)
60
- i18n (1.5.3)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ builder (3.2.4)
70
+ byebug (11.1.3)
71
+ concurrent-ruby (1.1.9)
72
+ crass (1.0.6)
73
+ diff-lcs (1.4.4)
74
+ erubi (1.10.0)
75
+ globalid (0.6.0)
76
+ activesupport (>= 5.0)
77
+ i18n (1.8.11)
61
78
  concurrent-ruby (~> 1.0)
62
- loofah (2.4.0)
79
+ loofah (2.12.0)
63
80
  crass (~> 1.0.2)
64
81
  nokogiri (>= 1.5.9)
65
82
  mail (2.7.1)
66
83
  mini_mime (>= 0.1.1)
67
- marcel (0.3.3)
68
- mimemagic (~> 0.3.2)
69
- method_source (0.9.2)
70
- mimemagic (0.3.3)
71
- mini_mime (1.0.1)
72
- mini_portile2 (2.4.0)
73
- minitest (5.11.3)
74
- nio4r (2.3.1)
75
- nokogiri (1.10.5)
76
- mini_portile2 (~> 2.4.0)
77
- rack (2.0.8)
84
+ marcel (1.0.2)
85
+ method_source (1.0.0)
86
+ mini_mime (1.1.2)
87
+ mini_portile2 (2.6.1)
88
+ minitest (5.14.4)
89
+ nio4r (2.5.8)
90
+ nokogiri (1.12.5)
91
+ mini_portile2 (~> 2.6.1)
92
+ racc (~> 1.4)
93
+ racc (1.6.0)
94
+ rack (2.2.3)
78
95
  rack-test (1.1.0)
79
96
  rack (>= 1.0, < 3)
80
- rails (5.2.2)
81
- actioncable (= 5.2.2)
82
- actionmailer (= 5.2.2)
83
- actionpack (= 5.2.2)
84
- actionview (= 5.2.2)
85
- activejob (= 5.2.2)
86
- activemodel (= 5.2.2)
87
- activerecord (= 5.2.2)
88
- activestorage (= 5.2.2)
89
- activesupport (= 5.2.2)
90
- bundler (>= 1.3.0)
91
- railties (= 5.2.2)
97
+ rails (6.1.4.1)
98
+ actioncable (= 6.1.4.1)
99
+ actionmailbox (= 6.1.4.1)
100
+ actionmailer (= 6.1.4.1)
101
+ actionpack (= 6.1.4.1)
102
+ actiontext (= 6.1.4.1)
103
+ actionview (= 6.1.4.1)
104
+ activejob (= 6.1.4.1)
105
+ activemodel (= 6.1.4.1)
106
+ activerecord (= 6.1.4.1)
107
+ activestorage (= 6.1.4.1)
108
+ activesupport (= 6.1.4.1)
109
+ bundler (>= 1.15.0)
110
+ railties (= 6.1.4.1)
92
111
  sprockets-rails (>= 2.0.0)
93
112
  rails-dom-testing (2.0.3)
94
113
  activesupport (>= 4.2.0)
95
114
  nokogiri (>= 1.6)
96
- rails-html-sanitizer (1.0.4)
97
- loofah (~> 2.2, >= 2.2.2)
98
- railties (5.2.2)
99
- actionpack (= 5.2.2)
100
- activesupport (= 5.2.2)
115
+ rails-html-sanitizer (1.4.2)
116
+ loofah (~> 2.3)
117
+ railties (6.1.4.1)
118
+ actionpack (= 6.1.4.1)
119
+ activesupport (= 6.1.4.1)
101
120
  method_source
102
- rake (>= 0.8.7)
103
- thor (>= 0.19.0, < 2.0)
104
- rake (12.3.2)
105
- rspec (3.4.0)
106
- rspec-core (~> 3.4.0)
107
- rspec-expectations (~> 3.4.0)
108
- rspec-mocks (~> 3.4.0)
109
- rspec-core (3.4.2)
110
- rspec-support (~> 3.4.0)
111
- rspec-expectations (3.4.0)
121
+ rake (>= 0.13)
122
+ thor (~> 1.0)
123
+ rake (13.0.6)
124
+ rspec (3.10.0)
125
+ rspec-core (~> 3.10.0)
126
+ rspec-expectations (~> 3.10.0)
127
+ rspec-mocks (~> 3.10.0)
128
+ rspec-core (3.10.1)
129
+ rspec-support (~> 3.10.0)
130
+ rspec-expectations (3.10.1)
112
131
  diff-lcs (>= 1.2.0, < 2.0)
113
- rspec-support (~> 3.4.0)
114
- rspec-mocks (3.4.1)
132
+ rspec-support (~> 3.10.0)
133
+ rspec-mocks (3.10.2)
115
134
  diff-lcs (>= 1.2.0, < 2.0)
116
- rspec-support (~> 3.4.0)
117
- rspec-support (3.4.1)
118
- sprockets (3.7.2)
135
+ rspec-support (~> 3.10.0)
136
+ rspec-support (3.10.2)
137
+ sprockets (4.0.2)
119
138
  concurrent-ruby (~> 1.0)
120
139
  rack (> 1, < 3)
121
- sprockets-rails (3.2.1)
122
- actionpack (>= 4.0)
123
- activesupport (>= 4.0)
140
+ sprockets-rails (3.4.1)
141
+ actionpack (>= 5.2)
142
+ activesupport (>= 5.2)
124
143
  sprockets (>= 3.0.0)
125
- thor (0.20.3)
126
- thread_safe (0.3.6)
127
- tzinfo (1.2.5)
128
- thread_safe (~> 0.1)
129
- websocket-driver (0.7.0)
144
+ thor (1.1.0)
145
+ tzinfo (2.0.4)
146
+ concurrent-ruby (~> 1.0)
147
+ websocket-driver (0.7.5)
130
148
  websocket-extensions (>= 0.1.0)
131
- websocket-extensions (0.1.3)
149
+ websocket-extensions (0.1.5)
150
+ zeitwerk (2.5.1)
132
151
 
133
152
  PLATFORMS
134
153
  ruby
@@ -139,4 +158,4 @@ DEPENDENCIES
139
158
  rspec
140
159
 
141
160
  BUNDLED WITH
142
- 1.17.2
161
+ 2.2.22
data/README.rdoc CHANGED
@@ -53,6 +53,24 @@ It gets recreated everytime you run the tasks - edit those translations in your
53
53
 
54
54
  TRANSLATE=en rake i18n:translate
55
55
 
56
+ === Node Package
57
+
58
+ Requires {i18n-js}[https://www.npmjs.com/package/i18n-js] as a peer dependency.
59
+
60
+ First install the npm-package
61
+
62
+ yarn add i18n-screwdriver
63
+
64
+ And then configure I18n with the i18n-screwdriver plugin
65
+
66
+ import I18n from "i18n-js"
67
+ import configure from "i18n-screwdriver"
68
+
69
+ configure(I18n)
70
+
71
+ I18n.screw("Your translations")
72
+
73
+
56
74
  == Test Helpers
57
75
 
58
76
  In your tests (functionals and integration) you can use the same translation helper
@@ -82,4 +100,4 @@ In your tests (functionals and integration) you can use the same translation hel
82
100
 
83
101
  == Copyright
84
102
 
85
- Copyright (c) 2010 - 2013 Tobias Miesel & {Corin Langosch}[http://www.corinlangosch.com]. Released unter the MIT license.
103
+ Copyright (c) 2010 - 2021 Tobias Miesel & {Corin Langosch}[http://www.corinlangosch.com]. Released unter the MIT license.
data/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ var n,t=(n=require("md5"))&&"object"==typeof n&&"default"in n?n.default:n;module.exports=function(n){n.screw=function(e,r){var o,i=t(e),u=null===(o=n.translations[n.locale])||void 0===o?void 0:o[i];return void 0===u&&(u=function(n,t,e){return"translation missing: "+n.locale+"."+e}(n,0,e)),function(n,t){return n.replace(/%{([^{}]*)}/g,function(n,e){return t[e]})}(u,r)}};
2
+ //# sourceMappingURL=index.js.map
data/dist/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../package/src/index.js"],"sourcesContent":["import md5 from \"md5\";\n\nfunction onMissingTranslation(I18n, md5, message) {\n return `translation missing: ${I18n.locale}.${message}`;\n}\n\nconst interpolate = (message, data) =>\n message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);\n\nexport default function configure(I18n) {\n I18n.screw = function screw(message, data) {\n const hash = md5(message);\n let translation = I18n.translations[I18n.locale]?.[hash];\n if (typeof translation === \"undefined\") {\n translation = onMissingTranslation(I18n, hash, message);\n }\n return interpolate(translation, data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","replace","a","b","interpolate"],"mappings":"kGASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,SAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,GAInD,YAH2B,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IARjC,SAACA,EAASC,UAC5BD,EAAQS,QAAQ,eAAgB,SAACC,EAAGC,UAAMV,EAAKU,KAStCC,CAAYR,EAAaH"}
@@ -0,0 +1,2 @@
1
+ import n from"md5";export default function(r){r.screw=function(t,o){var i,e=n(t),u=null===(i=r.translations[r.locale])||void 0===i?void 0:i[e];return void 0===u&&(u=function(n,r,t){return"translation missing: "+n.locale+"."+t}(r,0,t)),function(n,r){return n.replace(/%{([^{}]*)}/g,function(n,t){return r[t]})}(u,o)}}
2
+ //# sourceMappingURL=index.modern.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.modern.js","sources":["../package/src/index.js"],"sourcesContent":["import md5 from \"md5\";\n\nfunction onMissingTranslation(I18n, md5, message) {\n return `translation missing: ${I18n.locale}.${message}`;\n}\n\nconst interpolate = (message, data) =>\n message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);\n\nexport default function configure(I18n) {\n I18n.screw = function screw(message, data) {\n const hash = md5(message);\n let translation = I18n.translations[I18n.locale]?.[hash];\n if (typeof translation === \"undefined\") {\n translation = onMissingTranslation(I18n, hash, message);\n }\n return interpolate(translation, data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","replace","a","b","interpolate"],"mappings":"2CASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,SAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,GAInD,YAH2B,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IARjC,SAACA,EAASC,UAC5BD,EAAQS,QAAQ,eAAgB,SAACC,EAAGC,UAAMV,EAAKU,KAStCC,CAAYR,EAAaH"}
@@ -0,0 +1,2 @@
1
+ import n from"md5";export default function(r){r.screw=function(t,o){var i,e=n(t),u=null===(i=r.translations[r.locale])||void 0===i?void 0:i[e];return void 0===u&&(u=function(n,r,t){return"translation missing: "+n.locale+"."+t}(r,0,t)),function(n,r){return n.replace(/%{([^{}]*)}/g,function(n,t){return r[t]})}(u,o)}}
2
+ //# sourceMappingURL=index.module.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.module.js","sources":["../package/src/index.js"],"sourcesContent":["import md5 from \"md5\";\n\nfunction onMissingTranslation(I18n, md5, message) {\n return `translation missing: ${I18n.locale}.${message}`;\n}\n\nconst interpolate = (message, data) =>\n message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);\n\nexport default function configure(I18n) {\n I18n.screw = function screw(message, data) {\n const hash = md5(message);\n let translation = I18n.translations[I18n.locale]?.[hash];\n if (typeof translation === \"undefined\") {\n translation = onMissingTranslation(I18n, hash, message);\n }\n return interpolate(translation, data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","replace","a","b","interpolate"],"mappings":"2CASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,SAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,GAInD,YAH2B,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IARjC,SAACA,EAASC,UAC5BD,EAAQS,QAAQ,eAAgB,SAACC,EAAGC,UAAMV,EAAKU,KAStCC,CAAYR,EAAaH"}
data/dist/index.umd.js ADDED
@@ -0,0 +1,2 @@
1
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("md5")):"function"==typeof define&&define.amd?define(["md5"],n):(e=e||self).i18NScrewdriver=n(e.md5)}(this,function(e){return e=e&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e,function(n){n.screw=function(t,o){var r,i=e(t),u=null===(r=n.translations[n.locale])||void 0===r?void 0:r[i];return void 0===u&&(u=function(e,n,t){return"translation missing: "+e.locale+"."+t}(n,0,t)),function(e,n){return e.replace(/%{([^{}]*)}/g,function(e,t){return n[t]})}(u,o)}}});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../package/src/index.js"],"sourcesContent":["import md5 from \"md5\";\n\nfunction onMissingTranslation(I18n, md5, message) {\n return `translation missing: ${I18n.locale}.${message}`;\n}\n\nconst interpolate = (message, data) =>\n message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);\n\nexport default function configure(I18n) {\n I18n.screw = function screw(message, data) {\n const hash = md5(message);\n let translation = I18n.translations[I18n.locale]?.[hash];\n if (typeof translation === \"undefined\") {\n translation = onMissingTranslation(I18n, hash, message);\n }\n return interpolate(translation, data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","replace","a","b","interpolate"],"mappings":"uSASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,SAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,GAInD,YAH2B,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IARjC,SAACA,EAASC,UAC5BD,EAAQS,QAAQ,eAAgB,SAACC,EAAGC,UAAMV,EAAKU,KAStCC,CAAYR,EAAaH"}
@@ -4,8 +4,8 @@ module I18nScrewdriver
4
4
 
5
5
  attr_accessor :text, :options
6
6
 
7
- def self.new(text, options = {}, &block)
8
- translation = super(options[:raw] ? text : I18nScrewdriver.translate(text, options))
7
+ def self.new(text, **options, &block)
8
+ translation = super(options[:raw] ? text : I18nScrewdriver.translate(text, **options))
9
9
  translation.text = text
10
10
  translation.options = options
11
11
 
@@ -1,7 +1,7 @@
1
1
  module I18nScrewdriver
2
2
  module TranslationHelper
3
- def _(text, options = {}, &block)
4
- Translation.new(text, options, &block)
3
+ def _(text, **options, &block)
4
+ Translation.new(text, **options, &block)
5
5
  end
6
6
  end
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module I18nScrewdriver
2
- VERSION = "10.6.0"
2
+ VERSION = "10.7.1"
3
3
  end
@@ -175,10 +175,10 @@ module I18nScrewdriver
175
175
  end
176
176
  end
177
177
 
178
- def self.translate(string, options = {})
179
- I18n.translate!(generate_key(string), options)
178
+ def self.translate(string, **options)
179
+ I18n.translate!(generate_key(string), **options)
180
180
  rescue I18n::MissingTranslationData
181
- I18n.translate(string, options)
181
+ I18n.translate(string, **options)
182
182
  end
183
183
 
184
184
  def self.extract_text(string)
@@ -0,0 +1,19 @@
1
+ import md5 from "md5";
2
+
3
+ function onMissingTranslation(I18n, md5, message) {
4
+ return `translation missing: ${I18n.locale}.${message}`;
5
+ }
6
+
7
+ const interpolate = (message, data) =>
8
+ message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);
9
+
10
+ export default function configure(I18n) {
11
+ I18n.screw = function screw(message, data) {
12
+ const hash = md5(message);
13
+ let translation = I18n.translations[I18n.locale]?.[hash];
14
+ if (typeof translation === "undefined") {
15
+ translation = onMissingTranslation(I18n, hash, message);
16
+ }
17
+ return interpolate(translation, data);
18
+ };
19
+ }
data/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "i18n-screwdriver",
3
+ "version": "11.0.1",
4
+ "description": "Node package for the i18n_screwdriver gem",
5
+ "source": "package/src/index.js",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.module.js",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "scripts": {
12
+ "build": "rimraf dist && microbundle",
13
+ "dev": "microbundle watch",
14
+ "test": "echo \"Error: no test specified\" && exit 1"
15
+ },
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/agileapplications/i18n_screwdriver.git"
19
+ },
20
+ "keywords": [
21
+ "i18n",
22
+ "translations"
23
+ ],
24
+ "license": "MIT",
25
+ "bugs": {
26
+ "url": "https://github.com/agileapplications/i18n_screwdriver/issues"
27
+ },
28
+ "homepage": "https://github.com/agileapplications/i18n_screwdriver#readme",
29
+ "devDependencies": {
30
+ "@babel/plugin-proposal-optional-chaining": "^7.9.0",
31
+ "microbundle": "^0.12.0-next.9",
32
+ "rimraf": "^3.0.2"
33
+ },
34
+ "dependencies": {
35
+ "md5": "^2.2.1"
36
+ },
37
+ "peerDependencies": {
38
+ "i18n-js": "^3.5.1"
39
+ },
40
+ "directories": {
41
+ "lib": "lib"
42
+ }
43
+ }