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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +155 -105
- data/app/assets/javascrips/i18n_screwdriver/screw.js +3 -1
- data/dist/index.js +1 -1
- data/dist/index.js.map +1 -1
- data/dist/index.modern.js +1 -1
- data/dist/index.modern.js.map +1 -1
- data/dist/index.module.js +1 -1
- data/dist/index.module.js.map +1 -1
- data/dist/index.umd.js +1 -1
- data/dist/index.umd.js.map +1 -1
- data/lib/i18n_screwdriver/version.rb +1 -1
- data/lib/i18n_screwdriver.rb +2 -7
- data/package/src/index.js +3 -1
- data/package.json +1 -1
- data/spec/i18n_screwdriver_spec.rb +14 -0
- data/spec/locales/en.yml +1 -0
- data/spec/locales/it.yml +1 -0
- metadata +11 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ec4e2dd6e5595792c6bf93b84187267f6faead77feeac773a3a73cd609c1f43
|
4
|
+
data.tar.gz: 6aca0ad64a1846c7cd7c7c4bb81a6ff4597d4baa187e0085881d6b9adf25893c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ff3bcc9e61cd4e782571faaab9b6c3ad5360f366f2bfc3b9027288c2588f5af60531cba4ccf65c678850deacd4ac7bb0824f3db265861e57022375230d855f
|
7
|
+
data.tar.gz: 20dfca1aae885335538e290470521e698b23b67ea754df489fefacd13aadb08bc6d03b772a37187a4e4340966893a7ca1045254521ea5a070daf1138413b27db
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,126 +1,180 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
i18n_screwdriver (
|
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 (
|
11
|
-
actionpack (=
|
12
|
-
activesupport (=
|
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
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
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.
|
35
|
-
rails-html-sanitizer (~> 1.
|
36
|
-
actiontext (
|
37
|
-
actionpack (=
|
38
|
-
activerecord (=
|
39
|
-
activestorage (=
|
40
|
-
activesupport (=
|
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 (
|
43
|
-
activesupport (=
|
53
|
+
actionview (7.1.5)
|
54
|
+
activesupport (= 7.1.5)
|
44
55
|
builder (~> 3.1)
|
45
|
-
erubi (~> 1.
|
46
|
-
rails-dom-testing (~> 2.
|
47
|
-
rails-html-sanitizer (~> 1.
|
48
|
-
activejob (
|
49
|
-
activesupport (=
|
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 (
|
52
|
-
activesupport (=
|
53
|
-
activerecord (
|
54
|
-
activemodel (=
|
55
|
-
activesupport (=
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
activesupport (
|
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
|
-
|
69
|
-
|
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.
|
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
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
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.
|
82
|
-
mail (2.
|
110
|
+
nokogiri (>= 1.12.0)
|
111
|
+
mail (2.8.1)
|
83
112
|
mini_mime (>= 0.1.1)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
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 (=
|
111
|
-
|
112
|
-
|
113
|
-
|
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.
|
116
|
-
loofah (~> 2.
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
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.
|
197
|
+
websocket-driver (0.7.6)
|
148
198
|
websocket-extensions (>= 0.1.0)
|
149
199
|
websocket-extensions (0.1.5)
|
150
|
-
zeitwerk (2.
|
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
|
-
|
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
|
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(
|
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,
|
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
|
data/dist/index.modern.js.map
CHANGED
@@ -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(
|
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,
|
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
|
data/dist/index.module.js.map
CHANGED
@@ -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(
|
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),
|
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
|
data/dist/index.umd.js.map
CHANGED
@@ -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(
|
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"}
|
data/lib/i18n_screwdriver.rb
CHANGED
@@ -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),
|
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
|
-
|
17
|
+
|
18
|
+
const [context, phrase] = translation.split("|");
|
19
|
+
return interpolate(phrase ?? context ?? "", data);
|
18
20
|
};
|
19
21
|
}
|
data/package.json
CHANGED
@@ -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
data/spec/locales/it.yml
CHANGED
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:
|
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:
|
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.
|
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
|