i18n_screwdriver 10.7.2 → 12.0.0

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: 57a6bec82c2faf9f7cc122a4066d757dc2f9e0c558a8de17221b5b12f5d78942
4
- data.tar.gz: e537c9bd5db20c19af05c82f82e1f79ff7ade1c9a533ac61bdc7ffeebc68e16a
3
+ metadata.gz: 6ec4e2dd6e5595792c6bf93b84187267f6faead77feeac773a3a73cd609c1f43
4
+ data.tar.gz: 6aca0ad64a1846c7cd7c7c4bb81a6ff4597d4baa187e0085881d6b9adf25893c
5
5
  SHA512:
6
- metadata.gz: 27e340aae80efaa77983dd81f813e465edafc6070881145d04d37ba9f1034b24c67ca8160338712d43b5c74dc06525bf59706309a9cec6d676c4874319ff4826
7
- data.tar.gz: 7db431175c45025d4ca6e3965bc3495f78c598cf417e63fa71d3dc97664f3b43159bd861b1bdec9914152c732286955be844fc78ec3c8cd7c33459a273a6aefd
6
+ metadata.gz: 07ff3bcc9e61cd4e782571faaab9b6c3ad5360f366f2bfc3b9027288c2588f5af60531cba4ccf65c678850deacd4ac7bb0824f3db265861e57022375230d855f
7
+ data.tar.gz: 20dfca1aae885335538e290470521e698b23b67ea754df489fefacd13aadb08bc6d03b772a37187a4e4340966893a7ca1045254521ea5a070daf1138413b27db
data/.gitignore CHANGED
@@ -3,6 +3,7 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  node_modules/
6
+ vendor/bundle
6
7
 
7
8
  .idea
8
9
 
data/Gemfile.lock CHANGED
@@ -1,126 +1,180 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n_screwdriver (10.7.0)
4
+ i18n_screwdriver (12.0.0)
5
5
  rails (>= 3.0.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- actioncable (6.1.4.1)
11
- actionpack (= 6.1.4.1)
12
- activesupport (= 6.1.4.1)
10
+ actioncable (7.1.5)
11
+ actionpack (= 7.1.5)
12
+ activesupport (= 7.1.5)
13
13
  nio4r (~> 2.0)
14
14
  websocket-driver (>= 0.6.1)
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)
15
+ zeitwerk (~> 2.6)
16
+ actionmailbox (7.1.5)
17
+ actionpack (= 7.1.5)
18
+ activejob (= 7.1.5)
19
+ activerecord (= 7.1.5)
20
+ activestorage (= 7.1.5)
21
+ activesupport (= 7.1.5)
21
22
  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)
23
+ net-imap
24
+ net-pop
25
+ net-smtp
26
+ actionmailer (7.1.5)
27
+ actionpack (= 7.1.5)
28
+ actionview (= 7.1.5)
29
+ activejob (= 7.1.5)
30
+ activesupport (= 7.1.5)
27
31
  mail (~> 2.5, >= 2.5.4)
28
- rails-dom-testing (~> 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)
32
+ net-imap
33
+ net-pop
34
+ net-smtp
35
+ rails-dom-testing (~> 2.2)
36
+ actionpack (7.1.5)
37
+ actionview (= 7.1.5)
38
+ activesupport (= 7.1.5)
39
+ nokogiri (>= 1.8.5)
40
+ racc
41
+ rack (>= 2.2.4)
42
+ rack-session (>= 1.0.1)
33
43
  rack-test (>= 0.6.3)
34
- rails-dom-testing (~> 2.0)
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)
44
+ rails-dom-testing (~> 2.2)
45
+ rails-html-sanitizer (~> 1.6)
46
+ actiontext (7.1.5)
47
+ actionpack (= 7.1.5)
48
+ activerecord (= 7.1.5)
49
+ activestorage (= 7.1.5)
50
+ activesupport (= 7.1.5)
51
+ globalid (>= 0.6.0)
41
52
  nokogiri (>= 1.8.5)
42
- actionview (6.1.4.1)
43
- activesupport (= 6.1.4.1)
53
+ actionview (7.1.5)
54
+ activesupport (= 7.1.5)
44
55
  builder (~> 3.1)
45
- erubi (~> 1.4)
46
- rails-dom-testing (~> 2.0)
47
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
- activejob (6.1.4.1)
49
- activesupport (= 6.1.4.1)
56
+ erubi (~> 1.11)
57
+ rails-dom-testing (~> 2.2)
58
+ rails-html-sanitizer (~> 1.6)
59
+ activejob (7.1.5)
60
+ activesupport (= 7.1.5)
50
61
  globalid (>= 0.3.6)
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)
62
+ activemodel (7.1.5)
63
+ activesupport (= 7.1.5)
64
+ activerecord (7.1.5)
65
+ activemodel (= 7.1.5)
66
+ activesupport (= 7.1.5)
67
+ timeout (>= 0.4.0)
68
+ activestorage (7.1.5)
69
+ actionpack (= 7.1.5)
70
+ activejob (= 7.1.5)
71
+ activerecord (= 7.1.5)
72
+ activesupport (= 7.1.5)
73
+ marcel (~> 1.0)
74
+ activesupport (7.1.5)
75
+ base64
76
+ benchmark (>= 0.3)
77
+ bigdecimal
64
78
  concurrent-ruby (~> 1.0, >= 1.0.2)
79
+ connection_pool (>= 2.2.5)
80
+ drb
65
81
  i18n (>= 1.6, < 2)
82
+ logger (>= 1.4.2)
66
83
  minitest (>= 5.1)
84
+ mutex_m
85
+ securerandom (>= 0.3)
67
86
  tzinfo (~> 2.0)
68
- zeitwerk (~> 2.3)
69
- builder (3.2.4)
87
+ base64 (0.2.0)
88
+ benchmark (0.4.0)
89
+ bigdecimal (3.1.8)
90
+ builder (3.3.0)
70
91
  byebug (11.1.3)
71
- concurrent-ruby (1.1.9)
92
+ concurrent-ruby (1.3.4)
93
+ connection_pool (2.4.1)
72
94
  crass (1.0.6)
95
+ date (3.4.0)
73
96
  diff-lcs (1.4.4)
74
- erubi (1.10.0)
75
- globalid (0.6.0)
76
- activesupport (>= 5.0)
77
- i18n (1.8.11)
97
+ drb (2.2.1)
98
+ erubi (1.13.0)
99
+ globalid (1.2.1)
100
+ activesupport (>= 6.1)
101
+ i18n (1.14.6)
78
102
  concurrent-ruby (~> 1.0)
79
- loofah (2.12.0)
103
+ io-console (0.7.2)
104
+ irb (1.14.1)
105
+ rdoc (>= 4.0.0)
106
+ reline (>= 0.4.2)
107
+ logger (1.6.1)
108
+ loofah (2.23.1)
80
109
  crass (~> 1.0.2)
81
- nokogiri (>= 1.5.9)
82
- mail (2.7.1)
110
+ nokogiri (>= 1.12.0)
111
+ mail (2.8.1)
83
112
  mini_mime (>= 0.1.1)
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)
113
+ net-imap
114
+ net-pop
115
+ net-smtp
116
+ marcel (1.0.4)
117
+ mini_mime (1.1.5)
118
+ mini_portile2 (2.8.8)
119
+ minitest (5.25.1)
120
+ mutex_m (0.3.0)
121
+ net-imap (0.4.18)
122
+ date
123
+ net-protocol
124
+ net-pop (0.1.2)
125
+ net-protocol
126
+ net-protocol (0.2.2)
127
+ timeout
128
+ net-smtp (0.5.0)
129
+ net-protocol
130
+ nio4r (2.7.4)
131
+ nokogiri (1.15.6)
132
+ mini_portile2 (~> 2.8.2)
92
133
  racc (~> 1.4)
93
- racc (1.6.0)
94
- rack (2.2.3)
95
- rack-test (1.1.0)
96
- rack (>= 1.0, < 3)
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)
134
+ psych (5.2.0)
135
+ stringio
136
+ racc (1.8.1)
137
+ rack (3.1.8)
138
+ rack-session (2.0.0)
139
+ rack (>= 3.0.0)
140
+ rack-test (2.1.0)
141
+ rack (>= 1.3)
142
+ rackup (2.2.1)
143
+ rack (>= 3)
144
+ rails (7.1.5)
145
+ actioncable (= 7.1.5)
146
+ actionmailbox (= 7.1.5)
147
+ actionmailer (= 7.1.5)
148
+ actionpack (= 7.1.5)
149
+ actiontext (= 7.1.5)
150
+ actionview (= 7.1.5)
151
+ activejob (= 7.1.5)
152
+ activemodel (= 7.1.5)
153
+ activerecord (= 7.1.5)
154
+ activestorage (= 7.1.5)
155
+ activesupport (= 7.1.5)
109
156
  bundler (>= 1.15.0)
110
- railties (= 6.1.4.1)
111
- sprockets-rails (>= 2.0.0)
112
- rails-dom-testing (2.0.3)
113
- activesupport (>= 4.2.0)
157
+ railties (= 7.1.5)
158
+ rails-dom-testing (2.2.0)
159
+ activesupport (>= 5.0.0)
160
+ minitest
114
161
  nokogiri (>= 1.6)
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)
120
- method_source
121
- rake (>= 0.13)
122
- thor (~> 1.0)
123
- rake (13.0.6)
162
+ rails-html-sanitizer (1.6.0)
163
+ loofah (~> 2.21)
164
+ nokogiri (~> 1.14)
165
+ railties (7.1.5)
166
+ actionpack (= 7.1.5)
167
+ activesupport (= 7.1.5)
168
+ irb
169
+ rackup (>= 1.0.0)
170
+ rake (>= 12.2)
171
+ thor (~> 1.0, >= 1.2.2)
172
+ zeitwerk (~> 2.6)
173
+ rake (13.2.1)
174
+ rdoc (6.8.1)
175
+ psych (>= 4.0.0)
176
+ reline (0.5.11)
177
+ io-console (~> 0.5)
124
178
  rspec (3.10.0)
125
179
  rspec-core (~> 3.10.0)
126
180
  rspec-expectations (~> 3.10.0)
@@ -134,20 +188,16 @@ GEM
134
188
  diff-lcs (>= 1.2.0, < 2.0)
135
189
  rspec-support (~> 3.10.0)
136
190
  rspec-support (3.10.2)
137
- sprockets (4.0.2)
138
- concurrent-ruby (~> 1.0)
139
- rack (> 1, < 3)
140
- sprockets-rails (3.4.1)
141
- actionpack (>= 5.2)
142
- activesupport (>= 5.2)
143
- sprockets (>= 3.0.0)
144
- thor (1.1.0)
145
- tzinfo (2.0.4)
191
+ securerandom (0.3.2)
192
+ stringio (3.1.2)
193
+ thor (1.3.2)
194
+ timeout (0.4.2)
195
+ tzinfo (2.0.6)
146
196
  concurrent-ruby (~> 1.0)
147
- websocket-driver (0.7.5)
197
+ websocket-driver (0.7.6)
148
198
  websocket-extensions (>= 0.1.0)
149
199
  websocket-extensions (0.1.5)
150
- zeitwerk (2.5.1)
200
+ zeitwerk (2.6.18)
151
201
 
152
202
  PLATFORMS
153
203
  ruby
@@ -9,5 +9,7 @@ I18n.screw = function(message, data) {
9
9
  if (translation == null) {
10
10
  translation = I18n.onMissingTranslation(md5, message);
11
11
  }
12
- return interpolate(translation, data);
12
+
13
+ const [context, phrase] = translation.split("|")
14
+ return interpolate(phrase ?? context ?? "", data);
13
15
  };
data/dist/index.js CHANGED
@@ -1,2 +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)}};
1
+ var n,t=(n=require("md5"))&&"object"==typeof n&&"default"in n?n.default:n;module.exports=function(n){n.screw=function(r,e){var l,o,u=t(r),i=null===(l=n.translations[n.locale])||void 0===l?void 0:l[u];void 0===i&&(i=function(n,t,r){return"translation missing: "+n.locale+"."+r}(n,0,r));var a=i.split("|"),c=a[1];return function(n,t){return n.replace(/%{([^{}]*)}/g,function(n,r){return t[r]})}(null!=(o=null!=c?c:a[0])?o:"",e)}};
2
2
  //# sourceMappingURL=index.js.map
data/dist/index.js.map CHANGED
@@ -1 +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"}
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\n const [context, phrase] = translation.split(\"|\");\n return interpolate(phrase ?? context ?? \"\", data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","split","phrase","replace","a","b","interpolate"],"mappings":"kGASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,WAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,QACxB,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IAJR,MAOfI,EAAYK,MAAM,KAA5BC,OAChB,OAZgB,SAACV,EAASC,UAC5BD,EAAQW,QAAQ,eAAgB,SAACC,EAAGC,UAAMZ,EAAKY,KAWtCC,gBAAYJ,EAAAA,UAAqB,GAAIT"}
data/dist/index.modern.js CHANGED
@@ -1,2 +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)}}
1
+ import n from"md5";export default function(r){r.screw=function(t,l){var o,i,u=n(t),e=null===(o=r.translations[r.locale])||void 0===o?void 0:o[u];void 0===e&&(e=function(n,r,t){return"translation missing: "+n.locale+"."+t}(r,0,t));var a=e.split("|"),c=a[1];return function(n,r){return n.replace(/%{([^{}]*)}/g,function(n,t){return r[t]})}(null!=(i=null!=c?c:a[0])?i:"",l)}}
2
2
  //# sourceMappingURL=index.modern.js.map
@@ -1 +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"}
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\n const [context, phrase] = translation.split(\"|\");\n return interpolate(phrase ?? context ?? \"\", data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","split","phrase","replace","a","b","interpolate"],"mappings":"2CASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,WAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,QACxB,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IAJR,MAOfI,EAAYK,MAAM,KAA5BC,OAChB,OAZgB,SAACV,EAASC,UAC5BD,EAAQW,QAAQ,eAAgB,SAACC,EAAGC,UAAMZ,EAAKY,KAWtCC,gBAAYJ,EAAAA,UAAqB,GAAIT"}
data/dist/index.module.js CHANGED
@@ -1,2 +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)}}
1
+ import n from"md5";export default function(r){r.screw=function(t,l){var o,i,u=n(t),e=null===(o=r.translations[r.locale])||void 0===o?void 0:o[u];void 0===e&&(e=function(n,r,t){return"translation missing: "+n.locale+"."+t}(r,0,t));var a=e.split("|"),c=a[1];return function(n,r){return n.replace(/%{([^{}]*)}/g,function(n,t){return r[t]})}(null!=(i=null!=c?c:a[0])?i:"",l)}}
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +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"}
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\n const [context, phrase] = translation.split(\"|\");\n return interpolate(phrase ?? context ?? \"\", data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","split","phrase","replace","a","b","interpolate"],"mappings":"2CASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,WAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,QACxB,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IAJR,MAOfI,EAAYK,MAAM,KAA5BC,OAChB,OAZgB,SAACV,EAASC,UAC5BD,EAAQW,QAAQ,eAAgB,SAACC,EAAGC,UAAMZ,EAAKY,KAWtCC,gBAAYJ,EAAAA,UAAqB,GAAIT"}
data/dist/index.umd.js CHANGED
@@ -1,2 +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)}}});
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,u=e(t),l=null===(r=n.translations[n.locale])||void 0===r?void 0:r[u];void 0===l&&(l=function(e,n,t){return"translation missing: "+e.locale+"."+t}(n,0,t));var f=l.split("|"),d=f[1];return function(e,n){return e.replace(/%{([^{}]*)}/g,function(e,t){return n[t]})}(null!=(i=null!=d?d:f[0])?i:"",o)}}});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +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"}
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\n const [context, phrase] = translation.split(\"|\");\n return interpolate(phrase ?? context ?? \"\", data);\n };\n}\n"],"names":["I18n","screw","message","data","hash","md5","translation","translations","locale","_I18n$translations$I","onMissingTranslation","split","phrase","replace","a","b","interpolate"],"mappings":"uSASkCA,GAChCA,EAAKC,MAAQ,SAAeC,EAASC,WAC7BC,EAAOC,EAAIH,GACbI,YAAcN,EAAKO,aAAaP,EAAKQ,4BAAvBC,EAAiCL,QACxB,IAAhBE,IACTA,EAZN,SAA8BN,EAAMK,EAAKH,GACvC,8BAA+BF,EAAKQ,WAAUN,EAW5BQ,CAAqBV,EAAMI,EAAMF,IAJR,MAOfI,EAAYK,MAAM,KAA5BC,OAChB,OAZgB,SAACV,EAASC,UAC5BD,EAAQW,QAAQ,eAAgB,SAACC,EAAGC,UAAMZ,EAAKY,KAWtCC,gBAAYJ,EAAAA,UAAqB,GAAIT"}
@@ -1,3 +1,3 @@
1
1
  module I18nScrewdriver
2
- VERSION = "10.7.2"
2
+ VERSION = "12.0.0"
3
3
  end
@@ -139,7 +139,7 @@ module I18nScrewdriver
139
139
  gather_js_translations(spec.full_gem_path, texts)
140
140
  end
141
141
 
142
- translations = Hash[texts.uniq.map{ |text| [generate_key(text), extract_text(text)] }]
142
+ translations = Hash[texts.uniq.map{ |text| [generate_key(text), text] }]
143
143
  translations.merge(Hash[symbols.uniq.map{ |symbol| [generate_key(symbol), ""] }])
144
144
  end
145
145
 
@@ -176,13 +176,8 @@ module I18nScrewdriver
176
176
  end
177
177
 
178
178
  def self.translate(string, **options)
179
- I18n.translate!(generate_key(string), **options)
179
+ I18n.translate!(generate_key(string), **options).split("|").last
180
180
  rescue I18n::MissingTranslationData
181
181
  I18n.translate(string, **options)
182
182
  end
183
-
184
- def self.extract_text(string)
185
- namespace, text = string.split("|", 2)
186
- text ? text : namespace
187
- end
188
183
  end
data/package/src/index.js CHANGED
@@ -14,6 +14,8 @@ export default function configure(I18n) {
14
14
  if (typeof translation === "undefined") {
15
15
  translation = onMissingTranslation(I18n, hash, message);
16
16
  }
17
- return interpolate(translation, data);
17
+
18
+ const [context, phrase] = translation.split("|");
19
+ return interpolate(phrase ?? context ?? "", data);
18
20
  };
19
21
  }
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "i18n-screwdriver",
3
- "version": "11.0.1",
3
+ "version": "12.0.0",
4
4
  "description": "Node package for the i18n_screwdriver gem",
5
5
  "source": "package/src/index.js",
6
6
  "main": "dist/index.js",
@@ -20,6 +20,10 @@ describe I18nScrewdriver do
20
20
  expect(I18nScrewdriver.grab_js_texts_to_be_translated(%|=I18n.screw(`Hi ${name}!`)"|)).to eq(["Hi ${name}!"])
21
21
  expect(I18nScrewdriver.grab_js_texts_to_be_translated(%|=I18n.screw(`Hi %{name}!`, name: "gucki")|)).to eq(["Hi %{name}!"])
22
22
  end
23
+
24
+ it "properly parses the passed string with context" do
25
+ expect(I18nScrewdriver.grab_js_texts_to_be_translated(%|=I18n.screw("context\|test!")|)).to eq(["context\|test!"])
26
+ end
23
27
  end
24
28
 
25
29
  describe "translates (oh really?)" do
@@ -36,6 +40,12 @@ describe I18nScrewdriver do
36
40
  I18n.locale = :it
37
41
  expect(I18nScrewdriver.translate(:intro_text)).to eq("un lungo testo introduttivo")
38
42
  end
43
+
44
+ it "translate a string with context" do
45
+ expect(I18nScrewdriver.translate("unit|day")).to eq("day")
46
+ I18n.locale = :it
47
+ expect(I18nScrewdriver.translate("unit|day")).to eq("giorno")
48
+ end
39
49
  end
40
50
 
41
51
  describe "grab_js_texts_to_be_translated with screw based method" do
@@ -46,5 +56,9 @@ describe I18nScrewdriver do
46
56
  expect(I18nScrewdriver.grab_js_texts_to_be_translated(%|=I18n.screwBasedMethod "test!"|)).to eq(["test!"])
47
57
  expect(I18nScrewdriver.grab_js_texts_to_be_translated(%|=I18n.screwBasedMethod "Hi %{name}!", name: "gucki"|)).to eq(["Hi %{name}!"])
48
58
  end
59
+
60
+ it "properly parses the passed string" do
61
+ expect(I18nScrewdriver.grab_js_texts_to_be_translated(%|=I18n.screwBasedMethod("context\|test!")|)).to eq(["context|test!"])
62
+ end
49
63
  end
50
64
  end
data/spec/locales/en.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  en:
2
2
  2b849500e4585dab4196ec9a415edf8f: 'good morning'
3
+ 4f6c7563c451ae067b4f7796924709f1: 'unit|day'
3
4
  ":intro_text": 'a long intro text'
data/spec/locales/it.yml CHANGED
@@ -1,3 +1,4 @@
1
1
  it:
2
2
  2b849500e4585dab4196ec9a415edf8f: 'buongiorno'
3
+ 4f6c7563c451ae067b4f7796924709f1: 'unit|giorno'
3
4
  ":intro_text": 'un lungo testo introduttivo'
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_screwdriver
3
3
  version: !ruby/object:Gem::Version
4
- version: 10.7.2
4
+ version: 12.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Miesel
8
8
  - Corin Langosch
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-03-01 00:00:00.000000000 Z
12
+ date: 2024-11-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -101,7 +101,7 @@ homepage: https://github.com/agileapplications/i18n_screwdriver
101
101
  licenses:
102
102
  - MIT
103
103
  metadata: {}
104
- post_install_message:
104
+ post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths:
107
107
  - lib
@@ -116,8 +116,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.0.3
120
- signing_key:
119
+ rubygems_version: 3.1.6
120
+ signing_key:
121
121
  specification_version: 4
122
122
  summary: make translating with rails i18n fun again
123
- test_files: []
123
+ test_files:
124
+ - spec/i18n_screwdriver_spec.rb
125
+ - spec/locales/en.yml
126
+ - spec/locales/it.yml
127
+ - spec/spec_helper.rb