i18n-js 4.2.1 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/i18n-js/clean_hash.rb +13 -0
- data/lib/i18n-js/sort_hash.rb +12 -0
- data/lib/i18n-js/version.rb +1 -1
- data/lib/i18n-js.rb +10 -0
- metadata +9 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4299c989d73925fef9ee5651623b38c8b89f334dba54781e91e093860dc4ebf
|
4
|
+
data.tar.gz: 07d036910ef839e283030f481e6845fab011f77311fe48def9a564885009ecbd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c45b7571d0854ce7eb5b225b382628ee3d4c682a640864f050e357d299fc9416f9885ed94518abf192e4a99956c10ab1ccfa6f7a61f954f89ce3efd60a6c78b6
|
7
|
+
data.tar.gz: '0087a9c072c0f84fac37fff95bddcc541e0a247ad6c924f4754c062ed066da77ed2d5c96d6511ffcb607ff4c0459296f9e1af42b6c6036d3365080c47a6dae4f'
|
data/CHANGELOG.md
CHANGED
@@ -11,6 +11,12 @@ Prefix your message with one of the following:
|
|
11
11
|
- [Security] in case of vulnerabilities.
|
12
12
|
-->
|
13
13
|
|
14
|
+
## v4.2.2 - Dec 30, 2022
|
15
|
+
|
16
|
+
- [Changed] Do not re-export files whose contents haven't changed.
|
17
|
+
- [Changed] Translations will always be deep sorted.
|
18
|
+
- [Fixed] Remove procs from translations before exporting files.
|
19
|
+
|
14
20
|
## v4.2.1 - Dec 25, 2022
|
15
21
|
|
16
22
|
- [Changed] Change plugin api to be based on instance methods. This avoids
|
@@ -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
|
@@ -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
|
data/lib/i18n-js/version.rb
CHANGED
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.
|
4
|
+
version: 4.2.2
|
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-
|
11
|
+
date: 2022-12-30 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.
|
227
|
-
changelog_uri: https://github.com/fnando/i18n-js/tree/v4.2.
|
228
|
-
documentation_uri: https://github.com/fnando/i18n-js/tree/v4.2.
|
229
|
-
license_uri: https://github.com/fnando/i18n-js/tree/v4.2.
|
228
|
+
source_code_uri: https://github.com/fnando/i18n-js/tree/v4.2.2
|
229
|
+
changelog_uri: https://github.com/fnando/i18n-js/tree/v4.2.2/CHANGELOG.md
|
230
|
+
documentation_uri: https://github.com/fnando/i18n-js/tree/v4.2.2/README.md
|
231
|
+
license_uri: https://github.com/fnando/i18n-js/tree/v4.2.2/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.
|
247
|
+
rubygems_version: 3.4.1
|
246
248
|
signing_key:
|
247
249
|
specification_version: 4
|
248
250
|
summary: Export i18n translations and use them on JavaScript.
|