i18n-js 3.8.3 → 3.8.4

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: 1ecff24d70edad3fce1aafa3f96872f4d7a9fc7a0ff7fdcb5fe112ee5f79d410
4
- data.tar.gz: ee563efe72631f54c5c36536803a3bf0c31fe1c98f996763a36921b14cf21c2a
3
+ metadata.gz: 228b00c6b2733537cc164228e6da21dfee1531b26186258861b2f710b7c80cae
4
+ data.tar.gz: 000d759f9753bb29900a7e09eca044f643cbdde5b0779eeb71683805ac780e14
5
5
  SHA512:
6
- metadata.gz: 59ebc7bd38d3cd451631107c711d1a53001d3677a073327fdb66c043d4c5f37b6f7429b0fd2e7ff495201b575670bb4baabdaccb5e3cbebabc973f17f9db74bf
7
- data.tar.gz: 9e841a4b949c5993894b3f74296ca7837594cc1d1a68552b1c840578694501ad3a163dca443fac0f9bd6fa2fc198aec3fbdf299da45f96a283fc1ce215d1bd72
6
+ metadata.gz: a180630b6968c7e38723f8d42828e3d9aa6c32d0250e2e28c4a56a644d6a943124bd7183908f5e05616237dc9ebefd69c21a1f0190f2995062745fb12f7b76d9
7
+ data.tar.gz: b301cb38ecf02cbf08b92798b0d7457fc00c1903f3fb27ca9c5d821c0c9fdf7f7f500b19b935a1eb3052a066b3057bc763635c4e0e8daf8f7448c500ffc90746
data/CHANGELOG.md CHANGED
@@ -18,6 +18,14 @@ This project adheres to [Semantic Versioning](http://semver.org/).
18
18
  - Nothing
19
19
 
20
20
 
21
+ ## [3.8.4]
22
+
23
+ ### Fixed
24
+
25
+ - [Ruby] Fix proc exported to JS/JSON file(s) causing issues like git merge conflicts
26
+ (PR: https://github.com/fnando/i18n-js/pull/591)
27
+
28
+
21
29
  ## [3.8.3]
22
30
 
23
31
  ### Changed
@@ -501,7 +509,8 @@ And today is not April Fools' Day
501
509
 
502
510
 
503
511
 
504
- [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.8.3...HEAD
512
+ [Unreleased]: https://github.com/fnando/i18n-js/compare/v3.8.4...HEAD
513
+ [3.8.4]: https://github.com/fnando/i18n-js/compare/v3.8.3...v3.8.4
505
514
  [3.8.3]: https://github.com/fnando/i18n-js/compare/v3.8.2...v3.8.3
506
515
  [3.8.2]: https://github.com/fnando/i18n-js/compare/v3.8.1...v3.8.2
507
516
  [3.8.1]: https://github.com/fnando/i18n-js/compare/v3.8.0...v3.8.1
@@ -50,6 +50,7 @@ module I18n
50
50
  def write_file(_file = @file, _translations = @translations)
51
51
  FileUtils.mkdir_p File.dirname(_file)
52
52
  _translations = Utils.deep_key_sort(_translations) if @sort_translation_keys
53
+ _translations = Utils.deep_remove_procs(_translations)
53
54
  contents = formatter.format(_translations)
54
55
 
55
56
  return if File.exist?(_file) && File.read(_file) == contents
data/lib/i18n/js/utils.rb CHANGED
@@ -73,6 +73,19 @@ module I18n
73
73
  seed[key] = value.is_a?(Hash) ? deep_key_sort(value) : value
74
74
  end
75
75
  end
76
+
77
+ def self.deep_remove_procs(hash)
78
+ # procs exist in `i18n.plural.rule` as pluralizer
79
+ # But having it in translation causes the exported JS/JSON changes every time
80
+ # https://github.com/ruby-i18n/i18n/blob/v1.8.7/lib/i18n/backend/pluralization.rb#L51
81
+ hash.keys.
82
+ each_with_object({}) do |key, seed|
83
+ value = hash[key]
84
+ next if value.is_a?(Proc)
85
+
86
+ seed[key] = value.is_a?(Hash) ? deep_remove_procs(value) : value
87
+ end
88
+ end
76
89
  end
77
90
  end
78
91
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module I18n
4
4
  module JS
5
- VERSION = "3.8.3"
5
+ VERSION = "3.8.4"
6
6
  end
7
7
  end
data/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "i18n"
9
9
  ],
10
10
  "devDependencies": {
11
- "jasmine-node": "^1.14.5"
11
+ "jasmine-node": "^3.0.0"
12
12
  },
13
13
  "main": "app/assets/javascripts/i18n.js",
14
14
  "scripts": {
@@ -257,5 +257,30 @@ MyNamespace.translations["en"] = I18n.extend((MyNamespace.translations["en"] ||
257
257
  EOF
258
258
  end
259
259
  end
260
+
261
+ context "when translation entries contain procs" do
262
+ let(:translations) do
263
+ {
264
+ en: {
265
+ "test" => "Test",
266
+ "i18n" => {"plural" => {"rule" => proc {} }},
267
+ },
268
+ fr: {
269
+ "test" => "Test2",
270
+ "i18n" => {"plural" => {"rule" => proc {} }},
271
+ },
272
+ }
273
+ end
274
+
275
+ it "should write files without procs or their string representations" do
276
+ file_should_exist "segment.js"
277
+
278
+ expect(File.open(File.join(temp_path, "segment.js")){|f| f.read}).to eql <<-EOF
279
+ MyNamespace.translations || (MyNamespace.translations = {});
280
+ MyNamespace.translations["en"] = I18n.extend((MyNamespace.translations["en"] || {}), JSON.parse('{"i18n":{"plural":{}},"test":"Test"}'));
281
+ MyNamespace.translations["fr"] = I18n.extend((MyNamespace.translations["fr"] || {}), JSON.parse('{"i18n":{"plural":{}},"test":"Test2"}'));
282
+ EOF
283
+ end
284
+ end
260
285
  end
261
286
  end
@@ -103,4 +103,36 @@ describe I18n::JS::Utils do
103
103
  expect(described_class.scopes_match?([:a, :b, :c], [:a, '*', '*'])).to eql true
104
104
  end
105
105
  end
106
+
107
+ describe ".deep_remove_procs" do
108
+ let(:proc_obj) { proc {} }
109
+ let(:hash_with_proc) do
110
+ {
111
+ :a => :b,
112
+ :c => proc_obj,
113
+ :d => {
114
+ :e => proc_obj,
115
+ :f => :g,
116
+ }
117
+ }
118
+ end
119
+ subject { described_class.deep_remove_procs(hash_with_proc) }
120
+
121
+ it "performs a deep keys sort without changing the original hash" do
122
+ should eql({
123
+ :a => :b,
124
+ :d => {
125
+ :f => :g,
126
+ }
127
+ })
128
+ expect(hash_with_proc).to eql({
129
+ :a => :b,
130
+ :c => proc_obj,
131
+ :d => {
132
+ :e => proc_obj,
133
+ :f => :g,
134
+ }
135
+ })
136
+ end
137
+ end
106
138
  end
data/yarn.lock CHANGED
@@ -13,9 +13,10 @@ brace-expansion@^1.1.7:
13
13
  balanced-match "^1.0.0"
14
14
  concat-map "0.0.1"
15
15
 
16
- coffeescript@>=1.0.1:
17
- version "2.3.1"
18
- resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-2.3.1.tgz#a25f69c251d25805c9842e57fc94bfc453ef6aed"
16
+ coffeescript@~1.12.7:
17
+ version "1.12.7"
18
+ resolved "https://registry.yarnpkg.com/coffeescript/-/coffeescript-1.12.7.tgz#e57ee4c4867cf7f606bfc4a0f2d550c0981ddd27"
19
+ integrity sha512-pLXHFxQMPklVoEekowk8b3erNynC+DVJzChxS/LCBBgR6/8AJkHivkm//zbowcfc7BTCAjryuhx6gPqPRfsFoA==
19
20
 
20
21
  concat-map@0.0.1:
21
22
  version "0.0.1"
@@ -50,9 +51,10 @@ globule@^1.0.0:
50
51
  lodash "~4.17.10"
51
52
  minimatch "~3.0.2"
52
53
 
53
- growl@^1.10.2:
54
+ growl@^1.10.5:
54
55
  version "1.10.5"
55
56
  resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e"
57
+ integrity sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==
56
58
 
57
59
  inflight@^1.0.4:
58
60
  version "1.0.6"
@@ -65,24 +67,26 @@ inherits@2:
65
67
  version "2.0.3"
66
68
  resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de"
67
69
 
68
- jasmine-growl-reporter@~1.0.1:
69
- version "1.0.1"
70
- resolved "https://registry.yarnpkg.com/jasmine-growl-reporter/-/jasmine-growl-reporter-1.0.1.tgz#375306cef1fbf6357ad7913ca0358aa2285d6d39"
70
+ jasmine-growl-reporter@~2.0.0:
71
+ version "2.0.0"
72
+ resolved "https://registry.yarnpkg.com/jasmine-growl-reporter/-/jasmine-growl-reporter-2.0.0.tgz#4943a2481193d66a8a68ee2f38b6c360fb037859"
73
+ integrity sha512-RYwVfPaGgxQQSHDOt6jQ99/KAkFQ/Fiwg/AzBS+uO9A4UhGhxb7hwXaUUSU/Zs0MxBoFNqmIRC+7P4/+5O3lXg==
71
74
  dependencies:
72
- growl "^1.10.2"
75
+ growl "^1.10.5"
73
76
 
74
- jasmine-node@^1.14.5:
75
- version "1.15.0"
76
- resolved "https://registry.yarnpkg.com/jasmine-node/-/jasmine-node-1.15.0.tgz#d5e9a92623c111f55e4b83ff2ab0407ddbc2a5b7"
77
+ jasmine-node@^3.0.0:
78
+ version "3.0.0"
79
+ resolved "https://registry.yarnpkg.com/jasmine-node/-/jasmine-node-3.0.0.tgz#f12b6fdd24633402ec23e8ea6fef6ffbcb464f90"
80
+ integrity sha512-vUa5Q7bQYwHHqi6FlJYndiKqZp+d+c3MKe0QUMwwrC4JRmoRV3zkg0buxB/uQ6qLh0NO34TNstpAnvaZ6xGlAA==
77
81
  dependencies:
78
- coffeescript ">=1.0.1"
82
+ coffeescript "~1.12.7"
79
83
  gaze "~1.1.2"
80
- jasmine-growl-reporter "~1.0.1"
84
+ jasmine-growl-reporter "~2.0.0"
81
85
  jasmine-reporters "~1.0.0"
82
86
  mkdirp "~0.3.5"
83
- requirejs ">=0.27.1"
84
- underscore ">= 1.3.1"
85
- walkdir ">= 0.0.1"
87
+ requirejs "~2.3.6"
88
+ underscore "~1.9.1"
89
+ walkdir "~0.0.12"
86
90
 
87
91
  jasmine-reporters@~1.0.0:
88
92
  version "1.0.2"
@@ -91,8 +95,8 @@ jasmine-reporters@~1.0.0:
91
95
  mkdirp "~0.3.5"
92
96
 
93
97
  lodash@~4.17.10:
94
- version "4.17.20"
95
- resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.20.tgz#b44a9b6297bcb698f1c51a3545a2b3b368d59c52"
98
+ version "4.17.21"
99
+ resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
96
100
 
97
101
  minimatch@^3.0.4, minimatch@~3.0.2:
98
102
  version "3.0.4"
@@ -114,17 +118,20 @@ path-is-absolute@^1.0.0:
114
118
  version "1.0.1"
115
119
  resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
116
120
 
117
- requirejs@>=0.27.1:
118
- version "2.3.5"
119
- resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.5.tgz#617b9acbbcb336540ef4914d790323a8d4b861b0"
121
+ requirejs@~2.3.6:
122
+ version "2.3.6"
123
+ resolved "https://registry.yarnpkg.com/requirejs/-/requirejs-2.3.6.tgz#e5093d9601c2829251258c0b9445d4d19fa9e7c9"
124
+ integrity sha512-ipEzlWQe6RK3jkzikgCupiTbTvm4S0/CAU5GlgptkN5SO6F3u0UD0K18wy6ErDqiCyP4J4YYe1HuAShvsxePLg==
120
125
 
121
- "underscore@>= 1.3.1":
122
- version "1.9.1"
123
- resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.1.tgz#06dce34a0e68a7babc29b365b8e74b8925203961"
126
+ underscore@~1.9.1:
127
+ version "1.9.2"
128
+ resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.9.2.tgz#0c8d6f536d6f378a5af264a72f7bec50feb7cf2f"
129
+ integrity sha512-D39qtimx0c1fI3ya1Lnhk3E9nONswSKhnffBI0gME9C99fYOkNi04xs8K6pePLhvl1frbDemkaBQ5ikWllR2HQ==
124
130
 
125
- "walkdir@>= 0.0.1":
131
+ walkdir@~0.0.12:
126
132
  version "0.0.12"
127
133
  resolved "https://registry.yarnpkg.com/walkdir/-/walkdir-0.0.12.tgz#2f24f1ade64aab1e458591d4442c8868356e9281"
134
+ integrity sha512-HFhaD4mMWPzFSqhpyDG48KDdrjfn409YQuVW7ckZYhW4sE87mYtWifdB/+73RA7+p4s4K18n5Jfx1kHthE1gBw==
128
135
 
129
136
  wrappy@1:
130
137
  version "1.0.2"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n-js
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.3
4
+ version: 3.8.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-21 00:00:00.000000000 Z
11
+ date: 2021-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: i18n
@@ -227,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
227
227
  - !ruby/object:Gem::Version
228
228
  version: '0'
229
229
  requirements: []
230
- rubygems_version: 3.2.17
230
+ rubygems_version: 3.2.24
231
231
  signing_key:
232
232
  specification_version: 4
233
233
  summary: It's a small library to provide the Rails I18n translations on the Javascript.