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 +4 -4
- data/.github/workflows/ruby-tests.yml +1 -1
- data/CHANGELOG.md +10 -0
- data/MIGRATING_FROM_V3_TO_V4.md +1 -0
- data/lib/i18n-js/clean_hash.rb +13 -0
- data/lib/i18n-js/cli/lint_scripts_command.rb +2 -0
- data/lib/i18n-js/cli/lint_translations_command.rb +3 -1
- 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: '08fcf5b6b9e3cff755d11708a88e88cc8d30609251cba16f52e396a86014ac85'
|
4
|
+
data.tar.gz: 90b3fa30d3e6115fe76f81b5621caba070160cf585890f122aa8f646ee10fd2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 02d7a1a0d46b452727465a35cc9a9c46f4e8fe3d0baee2680e75d70fd6512972c7a28481795f9d0a07295612bd8553b932fb27fae2e86f83adc39e4d8aec5209
|
7
|
+
data.tar.gz: 9987a9679a3aa39f50f70e4b7b67469c2c7549b61b738f3104b837119a1afeb253e932119f24bdb39f29ffdb9b1840aa4f9b20035d1a70f71e51cfc8f0310b03
|
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
|
data/MIGRATING_FROM_V3_TO_V4.md
CHANGED
@@ -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
|
@@ -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
|
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.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:
|
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.
|
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.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.
|
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.
|