i18n-js 4.2.1 → 4.2.3

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: 0545bfe4fee26d8a5aed4aec6262e8a3db733ac951dbb0111f05e8fb2488e516
4
- data.tar.gz: 50dd6e5e4e019f01e7b72fcfacb71faf2faa73ed7157082c647432b4ef96f263
3
+ metadata.gz: '08fcf5b6b9e3cff755d11708a88e88cc8d30609251cba16f52e396a86014ac85'
4
+ data.tar.gz: 90b3fa30d3e6115fe76f81b5621caba070160cf585890f122aa8f646ee10fd2e
5
5
  SHA512:
6
- metadata.gz: b5366522c08e868ce0b555a4d0c0d10029bbee9270cb9602600f1ca4f2e89473f02baa577644dd5ae9a38046c3c03abf6c66029d79bac7d4ca41f50ed6ea4b86
7
- data.tar.gz: c3a0670b398c51c9bd1e01b163c46b2e69fe8f4ee06a099d8d46dc78ee57da1e78bff51e35db98ddb15b91fe2f422c8a8584fadb0b4066dc191a01eab65adac4
6
+ metadata.gz: 02d7a1a0d46b452727465a35cc9a9c46f4e8fe3d0baee2680e75d70fd6512972c7a28481795f9d0a07295612bd8553b932fb27fae2e86f83adc39e4d8aec5209
7
+ data.tar.gz: 9987a9679a3aa39f50f70e4b7b67469c2c7549b61b738f3104b837119a1afeb253e932119f24bdb39f29ffdb9b1840aa4f9b20035d1a70f71e51cfc8f0310b03
@@ -44,7 +44,7 @@ jobs:
44
44
  hashFiles('package.json') }}
45
45
 
46
46
  - name: Set up Node
47
- uses: actions/setup-node@v3.5.1
47
+ uses: actions/setup-node@v3.6.0
48
48
  with:
49
49
  node-version: ${{ matrix.node }}
50
50
 
data/CHANGELOG.md CHANGED
@@ -11,6 +11,16 @@ Prefix your message with one of the following:
11
11
  - [Security] in case of vulnerabilities.
12
12
  -->
13
13
 
14
+ ## v4.2.3 - Mar 29, 2023
15
+
16
+ - [Fixed] Load plugins when running `i18n lint:*` commands.
17
+
18
+ ## v4.2.2 - Dec 30, 2022
19
+
20
+ - [Changed] Do not re-export files whose contents haven't changed.
21
+ - [Changed] Translations will always be deep sorted.
22
+ - [Fixed] Remove procs from translations before exporting files.
23
+
14
24
  ## v4.2.1 - Dec 25, 2022
15
25
 
16
26
  - [Changed] Change plugin api to be based on instance methods. This avoids
@@ -167,6 +167,7 @@ translations:
167
167
  - file: "app/assets/javascripts/everything_else.js"
168
168
  patterns:
169
169
  # Notice the exclamation mark.
170
+ - "*"
170
171
  - "!*.activerecord"
171
172
  - "!*.admin.*.title"
172
173
  - "!*.date.formats"
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module I18nJS
4
+ def self.clean_hash(hash)
5
+ hash.keys.each_with_object({}) do |key, buffer|
6
+ value = hash[key]
7
+
8
+ next if value.is_a?(Proc)
9
+
10
+ buffer[key] = value.is_a?(Hash) ? clean_hash(value) : value
11
+ end
12
+ end
13
+ end
@@ -80,6 +80,8 @@ module I18nJS
80
80
  end
81
81
 
82
82
  config = load_config_file(config_file)
83
+ I18nJS.load_plugins!
84
+ I18nJS.initialize_plugins!(config: config)
83
85
  Schema.validate!(config)
84
86
 
85
87
  load_require_file!(require_file) if require_file
@@ -68,6 +68,8 @@ module I18nJS
68
68
  end
69
69
 
70
70
  config = load_config_file(config_file)
71
+ I18nJS.load_plugins!
72
+ I18nJS.initialize_plugins!(config: config)
71
73
  Schema.validate!(config)
72
74
 
73
75
  load_require_file!(require_file) if require_file
@@ -82,7 +84,7 @@ module I18nJS
82
84
  .map {|key| key.gsub(/^.*?\./, "") }
83
85
  end
84
86
 
85
- default_locale_keys = mapping.delete(default_locale)
87
+ default_locale_keys = mapping.delete(default_locale) || mapping
86
88
 
87
89
  if ignored_keys.any?
88
90
  ui.stdout_print "=> Check #{options[:config_file].inspect} for " \
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module I18nJS
4
+ def self.sort_hash(hash)
5
+ return hash unless hash.is_a?(Hash)
6
+
7
+ hash.keys.sort_by(&:to_s).each_with_object({}) do |key, seed|
8
+ value = hash[key]
9
+ seed[key] = value.is_a?(Hash) ? sort_hash(value) : value
10
+ end
11
+ end
12
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18nJS
4
- VERSION = "4.2.1"
4
+ VERSION = "4.2.3"
5
5
  end
data/lib/i18n-js.rb CHANGED
@@ -13,6 +13,8 @@ require "digest/md5"
13
13
  require_relative "i18n-js/schema"
14
14
  require_relative "i18n-js/version"
15
15
  require_relative "i18n-js/plugin"
16
+ require_relative "i18n-js/sort_hash"
17
+ require_relative "i18n-js/clean_hash"
16
18
 
17
19
  module I18nJS
18
20
  MissingConfigError = Class.new(StandardError)
@@ -51,6 +53,7 @@ module I18nJS
51
53
  end
52
54
  end
53
55
 
56
+ filtered_translations = sort_hash(clean_hash(filtered_translations))
54
57
  output_file_path = File.expand_path(group[:file])
55
58
  exported_files = []
56
59
 
@@ -74,6 +77,13 @@ module I18nJS
74
77
  digest = Digest::MD5.hexdigest(contents)
75
78
  file_path = file_path.gsub(/:digest/, digest)
76
79
 
80
+ # Don't rewrite the file if it already exists and has the same content.
81
+ # It helps the asset pipeline or webpack understand that file wasn't
82
+ # changed.
83
+ if File.exist?(file_path) && File.read(file_path) == contents
84
+ return file_path
85
+ end
86
+
77
87
  File.open(file_path, "w") do |file|
78
88
  file << contents
79
89
  end
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: 4.2.1
4
+ version: 4.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nando Vieira
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-26 00:00:00.000000000 Z
11
+ date: 2023-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: glob
@@ -197,6 +197,7 @@ files:
197
197
  - lib/guard/i18n-js/templates/Guardfile
198
198
  - lib/guard/i18n-js/version.rb
199
199
  - lib/i18n-js.rb
200
+ - lib/i18n-js/clean_hash.rb
200
201
  - lib/i18n-js/cli.rb
201
202
  - lib/i18n-js/cli/check_command.rb
202
203
  - lib/i18n-js/cli/command.rb
@@ -214,6 +215,7 @@ files:
214
215
  - lib/i18n-js/listen.rb
215
216
  - lib/i18n-js/plugin.rb
216
217
  - lib/i18n-js/schema.rb
218
+ - lib/i18n-js/sort_hash.rb
217
219
  - lib/i18n-js/version.rb
218
220
  - package.json
219
221
  homepage: https://github.com/fnando/i18n-js
@@ -223,10 +225,10 @@ metadata:
223
225
  rubygems_mfa_required: 'true'
224
226
  homepage_uri: https://github.com/fnando/i18n-js
225
227
  bug_tracker_uri: https://github.com/fnando/i18n-js/issues
226
- source_code_uri: https://github.com/fnando/i18n-js/tree/v4.2.1
227
- changelog_uri: https://github.com/fnando/i18n-js/tree/v4.2.1/CHANGELOG.md
228
- documentation_uri: https://github.com/fnando/i18n-js/tree/v4.2.1/README.md
229
- license_uri: https://github.com/fnando/i18n-js/tree/v4.2.1/LICENSE.md
228
+ source_code_uri: https://github.com/fnando/i18n-js/tree/v4.2.3
229
+ changelog_uri: https://github.com/fnando/i18n-js/tree/v4.2.3/CHANGELOG.md
230
+ documentation_uri: https://github.com/fnando/i18n-js/tree/v4.2.3/README.md
231
+ license_uri: https://github.com/fnando/i18n-js/tree/v4.2.3/LICENSE.md
230
232
  post_install_message:
231
233
  rdoc_options: []
232
234
  require_paths:
@@ -242,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
242
244
  - !ruby/object:Gem::Version
243
245
  version: '0'
244
246
  requirements: []
245
- rubygems_version: 3.3.7
247
+ rubygems_version: 3.4.6
246
248
  signing_key:
247
249
  specification_version: 4
248
250
  summary: Export i18n translations and use them on JavaScript.