i18n_screwdriver 10.3.0 → 10.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.babelrc +3 -0
- data/.gitignore +1 -0
- data/.ruby-version +1 -1
- data/Gemfile.lock +114 -95
- data/README.rdoc +19 -1
- data/app/assets/javascrips/i18n_screwdriver/config.js +5 -0
- data/app/assets/javascrips/i18n_screwdriver/screw.js +13 -0
- data/dist/index.js +2 -0
- data/dist/index.js.map +1 -0
- data/dist/index.modern.js +2 -0
- data/dist/index.modern.js.map +1 -0
- data/dist/index.module.js +2 -0
- data/dist/index.module.js.map +1 -0
- data/dist/index.umd.js +2 -0
- data/dist/index.umd.js.map +1 -0
- data/lib/i18n_screwdriver/translation.rb +2 -2
- data/lib/i18n_screwdriver/translation_helper.rb +2 -2
- data/lib/i18n_screwdriver/version.rb +1 -1
- data/lib/i18n_screwdriver.rb +3 -3
- data/package/src/index.js +19 -0
- data/package.json +43 -0
- data/yarn.lock +3219 -0
- metadata +17 -5
- data/app/assets/javascrips/i18n_screwdriver/config.coffee +0 -3
- data/app/assets/javascrips/i18n_screwdriver/screw.coffee +0 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4aebabf876501392f8a3690444d4c56d52d0096905e31e00bc3e7da5cb403d1a
|
4
|
+
data.tar.gz: '059bef8245a97bd656c422875c5404fa8474ee3479b71cb657c8053aaa994e18'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '02892bc1ec500fb139d49f2a3342cfd87a48793f03af0d5594d7c36197d4e108b99931e52e5b2c38c5ff06b3404519c08818bf96506f845dbab367ec2759e5cb'
|
7
|
+
data.tar.gz: db9129ab71bba74c09efcfce79a6e56a68b8f10da8404ef77e6ca55e5f6fa0feb524e7af250719cfb2016d5bc35bca065a717c106fd2680dacd71b2c7f984b1b
|
data/.babelrc
ADDED
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
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.
|
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 (
|
11
|
-
actionpack (=
|
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
|
-
|
15
|
-
actionpack (=
|
16
|
-
|
17
|
-
|
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 (
|
21
|
-
actionview (=
|
22
|
-
activesupport (=
|
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
|
27
|
-
|
28
|
-
|
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.
|
33
|
-
activejob (
|
34
|
-
activesupport (=
|
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 (
|
37
|
-
activesupport (=
|
38
|
-
activerecord (
|
39
|
-
activemodel (=
|
40
|
-
activesupport (=
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
activerecord (=
|
45
|
-
|
46
|
-
|
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 (>=
|
49
|
-
minitest (
|
50
|
-
tzinfo (~>
|
51
|
-
|
52
|
-
builder (3.2.
|
53
|
-
byebug (
|
54
|
-
concurrent-ruby (1.1.
|
55
|
-
crass (1.0.
|
56
|
-
diff-lcs (1.
|
57
|
-
erubi (1.
|
58
|
-
globalid (0.
|
59
|
-
activesupport (>=
|
60
|
-
i18n (1.
|
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.
|
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.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
rack (2.
|
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 (
|
81
|
-
actioncable (=
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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.
|
97
|
-
loofah (~> 2.
|
98
|
-
railties (
|
99
|
-
actionpack (=
|
100
|
-
activesupport (=
|
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.
|
103
|
-
thor (
|
104
|
-
rake (
|
105
|
-
rspec (3.
|
106
|
-
rspec-core (~> 3.
|
107
|
-
rspec-expectations (~> 3.
|
108
|
-
rspec-mocks (~> 3.
|
109
|
-
rspec-core (3.
|
110
|
-
rspec-support (~> 3.
|
111
|
-
rspec-expectations (3.
|
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.
|
114
|
-
rspec-mocks (3.
|
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.
|
117
|
-
rspec-support (3.
|
118
|
-
sprockets (
|
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.
|
122
|
-
actionpack (>=
|
123
|
-
activesupport (>=
|
140
|
+
sprockets-rails (3.4.1)
|
141
|
+
actionpack (>= 5.2)
|
142
|
+
activesupport (>= 5.2)
|
124
143
|
sprockets (>= 3.0.0)
|
125
|
-
thor (
|
126
|
-
|
127
|
-
|
128
|
-
|
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.
|
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
|
-
|
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 -
|
103
|
+
Copyright (c) 2010 - 2021 Tobias Miesel & {Corin Langosch}[http://www.corinlangosch.com]. Released unter the MIT license.
|
@@ -0,0 +1,13 @@
|
|
1
|
+
//= require i18n_screwdriver/md5
|
2
|
+
|
3
|
+
const interpolate = (message, data) =>
|
4
|
+
message.replace(/%{([^{}]*)}/g, (a, b) => data[b]);
|
5
|
+
|
6
|
+
I18n.screw = function(message, data) {
|
7
|
+
const md5 = window.md5(message);
|
8
|
+
let translation = I18n.translations[I18n.locale][md5];
|
9
|
+
if (translation == null) {
|
10
|
+
translation = I18n.onMissingTranslation(md5, message);
|
11
|
+
}
|
12
|
+
return interpolate(translation, data);
|
13
|
+
};
|
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
|
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
|
|
data/lib/i18n_screwdriver.rb
CHANGED
@@ -116,7 +116,7 @@ module I18nScrewdriver
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def self.gather_js_translations(path, texts)
|
119
|
-
Dir.glob("#{path}/**/*.{js,jsx,coffee,hamlc,ejs,erb}").each do |file|
|
119
|
+
Dir.glob("#{path}/**/*.{js,jsx,ts,tsx,coffee,hamlc,ejs,erb}").each do |file|
|
120
120
|
next unless File.file?(file)
|
121
121
|
next if excluded_path?(file)
|
122
122
|
puts "Scanning #{file}..."
|
@@ -175,8 +175,8 @@ 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
181
|
I18n.translate(string, options)
|
182
182
|
end
|
@@ -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
|
+
}
|