rails_translation_manager 1.3.0 → 1.4.0
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 +4 -0
- data/lib/rails_translation_manager/locale_checker/all_locales.rb +11 -3
- data/lib/rails_translation_manager/locale_checker.rb +4 -3
- data/lib/rails_translation_manager/version.rb +1 -1
- data/spec/rails_translation_manager/locale_checker/all_locales_spec.rb +24 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 328572b2e2f76e544577abf6e4294fbc18b39324be6804a41107d7961e3545dd
|
4
|
+
data.tar.gz: cff1f18b58513f7fc12b8b2473aabf1f24fa5841999935ce4288d1a3bb7bd0ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2f3f6c481946426f3be7f562dc63487c5b29d16000b309980f581bf08f8089aa17a909389c0caf72be0a719f787ce4453d3cd91f31987a110b953ea4b7aa8c5f
|
7
|
+
data.tar.gz: 4cedacbcb032ca11e17b64bd2c699c7caf802062b768c129d43ef52b0f11e064b7f8990596007f58a020ea053fb5ecb374f99d7980b215f669d3e5673c1e6af5
|
data/CHANGELOG.md
CHANGED
@@ -3,8 +3,9 @@
|
|
3
3
|
class AllLocales
|
4
4
|
attr_reader :locale_path
|
5
5
|
|
6
|
-
def initialize(locale_path)
|
6
|
+
def initialize(locale_path, skip_validation = [])
|
7
7
|
@locale_path = locale_path
|
8
|
+
@skip_validation = skip_validation
|
8
9
|
end
|
9
10
|
|
10
11
|
def generate
|
@@ -15,12 +16,12 @@ class AllLocales
|
|
15
16
|
paths.flat_map do |locale_group|
|
16
17
|
{
|
17
18
|
locale: locale_group[:locale],
|
18
|
-
keys: all_keys_for_locale(locale_group)
|
19
|
+
keys: all_keys_for_locale(locale_group),
|
19
20
|
}
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
23
|
-
|
24
|
+
private
|
24
25
|
|
25
26
|
def locale_file_paths
|
26
27
|
I18n.available_locales.map do |locale|
|
@@ -43,6 +44,13 @@ class AllLocales
|
|
43
44
|
def keys_from_file(locale_hash: nil, key_chain: nil, locale_keys: [], file_path: nil)
|
44
45
|
locale_hash ||= YAML.load_file(file_path)
|
45
46
|
keys = locale_hash.keys
|
47
|
+
|
48
|
+
keys.reject! do |key|
|
49
|
+
key_chain && @skip_validation.map { |prefix|
|
50
|
+
"#{key_chain}.#{key}".start_with? ".#{key_chain.split('.')[1]}.#{prefix}"
|
51
|
+
}.any?
|
52
|
+
end
|
53
|
+
|
46
54
|
keys.each do |key|
|
47
55
|
if locale_hash.fetch(key).is_a?(Hash)
|
48
56
|
keys_from_file(locale_hash: locale_hash.fetch(key), key_chain: "#{key_chain}.#{key}", locale_keys: locale_keys)
|
@@ -10,8 +10,9 @@ module RailsTranslationManager
|
|
10
10
|
MissingForeignLocales,
|
11
11
|
UndeclaredLocaleFiles].freeze
|
12
12
|
|
13
|
-
def initialize(locale_path)
|
13
|
+
def initialize(locale_path, skip_validation = [])
|
14
14
|
@locale_path = locale_path
|
15
|
+
@skip_validation = skip_validation
|
15
16
|
end
|
16
17
|
|
17
18
|
def validate_locales
|
@@ -21,7 +22,7 @@ module RailsTranslationManager
|
|
21
22
|
false
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
|
+
private
|
25
26
|
|
26
27
|
def output_result
|
27
28
|
errors = checker_errors.compact
|
@@ -46,7 +47,7 @@ module RailsTranslationManager
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def all_locales
|
49
|
-
@all_locales ||= AllLocales.new(locale_path).generate
|
50
|
+
@all_locales ||= AllLocales.new(locale_path, @skip_validation).generate
|
50
51
|
end
|
51
52
|
end
|
52
53
|
end
|
@@ -21,4 +21,28 @@ RSpec.describe AllLocales do
|
|
21
21
|
.to raise_error(AllLocales::NoLocaleFilesFound, 'No locale files found for the supplied path')
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
context "when some keys are excluded" do
|
26
|
+
it "generates an array of hashes without those keys" do
|
27
|
+
expect(described_class.new("spec/locales/out_of_sync/*.yml", skip_validation = %w{wrong_plural.one}).generate)
|
28
|
+
.to eq(
|
29
|
+
[
|
30
|
+
{ keys: %w[test wrong_plural wrong_plural.zero], locale: :en },
|
31
|
+
{ keys: %w[other_test], locale: :cy }
|
32
|
+
]
|
33
|
+
)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
context "when a key prefix is excluded" do
|
38
|
+
it "generates an array of hashes without those keys" do
|
39
|
+
expect(described_class.new("spec/locales/out_of_sync/*.yml", skip_validation = %w{wrong_plural}).generate)
|
40
|
+
.to eq(
|
41
|
+
[
|
42
|
+
{ keys: %w[test], locale: :en },
|
43
|
+
{ keys: %w[other_test], locale: :cy }
|
44
|
+
]
|
45
|
+
)
|
46
|
+
end
|
47
|
+
end
|
24
48
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_translation_manager
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edd Sowden
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|