rails_translation_manager 1.1.3 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/rails_translation_manager/locale_checker/missing_declared_locales.rb +30 -0
- data/lib/rails_translation_manager/locale_checker/undeclared_locale_files.rb +30 -0
- data/lib/rails_translation_manager/locale_checker.rb +4 -2
- data/lib/rails_translation_manager/version.rb +1 -1
- data/lib/rails_translation_manager.rb +2 -0
- data/spec/rails_translation_manager/locale_checker/missing_declared_locales_spec.rb +48 -0
- data/spec/rails_translation_manager/locale_checker/missing_english_locales_spec.rb +1 -1
- data/spec/rails_translation_manager/locale_checker/undeclared_locale_files_spec.rb +48 -0
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1698a9fc00bbc68d6a07e11ab9a61fa009cdf11ab0556c1634e6586ea7f8043f
|
4
|
+
data.tar.gz: b93eba9d7309f7e7184a548487592a684bc508afd87af84a6270a4abaa66f624
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8877d5f9a8b3baff02a1f62df4b5b8645297774cbb6fc583ff04b3c23c41298d093f8455253f803f7d21fbdbdf4a832b93d5b0582dda96df0a67eff49041be5
|
7
|
+
data.tar.gz: bd9f568b8f7c330c005b9c897179d3a37d0f4a88dd718af7135544fd47cd7719329139799c4d050f2a85de20a134b62bb85ad771017002f408faac92a3097e34
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MissingDeclaredLocales < BaseChecker
|
4
|
+
include LocaleCheckerHelper
|
5
|
+
|
6
|
+
def report
|
7
|
+
diff = compare
|
8
|
+
format_error_message(diff) unless diff.empty?
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def format_error_message(locales)
|
14
|
+
<<~OUTPUT.chomp
|
15
|
+
\e[31m[ERROR]\e[0m No locale files detected for:
|
16
|
+
|
17
|
+
#{locales.join("\n\n")}
|
18
|
+
|
19
|
+
\e[1mEither create these locale files or remove these locales from your I18n `available_locales` config.\e[22m
|
20
|
+
OUTPUT
|
21
|
+
end
|
22
|
+
|
23
|
+
def actual_locales
|
24
|
+
all_locales.map { |l| l[:locale] }
|
25
|
+
end
|
26
|
+
|
27
|
+
def compare
|
28
|
+
I18n.available_locales - actual_locales
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class UndeclaredLocaleFiles < BaseChecker
|
4
|
+
include LocaleCheckerHelper
|
5
|
+
|
6
|
+
def report
|
7
|
+
diff = compare
|
8
|
+
format_error_message(diff) unless diff.empty?
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def format_error_message(locales)
|
14
|
+
<<~OUTPUT.chomp
|
15
|
+
\e[31m[ERROR]\e[0m Undeclared locale file(s) detected for:
|
16
|
+
|
17
|
+
#{locales.join("\n\n")}
|
18
|
+
|
19
|
+
\e[1mEither declare these locale files or remove them from your locale files directory.\e[22m
|
20
|
+
OUTPUT
|
21
|
+
end
|
22
|
+
|
23
|
+
def actual_locales
|
24
|
+
all_locales.map { |l| l[:locale] }
|
25
|
+
end
|
26
|
+
|
27
|
+
def compare
|
28
|
+
actual_locales - I18n.available_locales
|
29
|
+
end
|
30
|
+
end
|
@@ -4,9 +4,11 @@ module RailsTranslationManager
|
|
4
4
|
class LocaleChecker
|
5
5
|
attr_reader :locale_path
|
6
6
|
|
7
|
-
CHECKER_CLASSES = [
|
7
|
+
CHECKER_CLASSES = [IncompatiblePlurals,
|
8
|
+
MissingDeclaredLocales,
|
9
|
+
MissingEnglishLocales,
|
8
10
|
MissingForeignLocales,
|
9
|
-
|
11
|
+
UndeclaredLocaleFiles].freeze
|
10
12
|
|
11
13
|
def initialize(locale_path)
|
12
14
|
@locale_path = locale_path
|
@@ -6,10 +6,12 @@ require "rails-i18n"
|
|
6
6
|
|
7
7
|
require "rails_translation_manager/locale_checker/base_checker"
|
8
8
|
require "rails_translation_manager/locale_checker/locale_checker_helper"
|
9
|
+
require "rails_translation_manager/locale_checker/missing_declared_locales"
|
9
10
|
require "rails_translation_manager/locale_checker/missing_foreign_locales"
|
10
11
|
require "rails_translation_manager/locale_checker/missing_english_locales"
|
11
12
|
require "rails_translation_manager/locale_checker/plural_forms"
|
12
13
|
require "rails_translation_manager/locale_checker/incompatible_plurals"
|
14
|
+
require "rails_translation_manager/locale_checker/undeclared_locale_files"
|
13
15
|
require "rails_translation_manager/locale_checker/all_locales"
|
14
16
|
require "rails_translation_manager/locale_checker"
|
15
17
|
require "rails_translation_manager/cleaner"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe MissingDeclaredLocales do
|
6
|
+
let(:all_locales) do
|
7
|
+
[
|
8
|
+
{
|
9
|
+
locale: :en,
|
10
|
+
keys: %w[browse.same_key]
|
11
|
+
},
|
12
|
+
{
|
13
|
+
locale: :cy,
|
14
|
+
keys: %w[browse.same_key]
|
15
|
+
}
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when there are missing locales" do
|
20
|
+
before do
|
21
|
+
I18n.available_locales = [:en, :cy, :pt]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "outputs the missing locales" do
|
25
|
+
expect(described_class.new(all_locales).report)
|
26
|
+
.to eq(
|
27
|
+
<<~OUTPUT.chomp
|
28
|
+
\e[31m[ERROR]\e[0m No locale files detected for:
|
29
|
+
|
30
|
+
pt
|
31
|
+
|
32
|
+
\e[1mEither create these locale files or remove these locales from your I18n `available_locales` config.\e[22m
|
33
|
+
OUTPUT
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when there aren't missing locales" do
|
39
|
+
before do
|
40
|
+
I18n.available_locales = [:en, :cy]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "outputs nil" do
|
44
|
+
expect(described_class.new(all_locales).report)
|
45
|
+
.to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "spec_helper"
|
4
|
+
|
5
|
+
RSpec.describe UndeclaredLocaleFiles do
|
6
|
+
let(:all_locales) do
|
7
|
+
[
|
8
|
+
{
|
9
|
+
locale: :en,
|
10
|
+
keys: %w[browse.same_key]
|
11
|
+
},
|
12
|
+
{
|
13
|
+
locale: :cy,
|
14
|
+
keys: %w[browse.same_key]
|
15
|
+
}
|
16
|
+
]
|
17
|
+
end
|
18
|
+
|
19
|
+
context "when there are undeclared locales" do
|
20
|
+
before do
|
21
|
+
I18n.available_locales = [:en]
|
22
|
+
end
|
23
|
+
|
24
|
+
it "outputs the missing locales" do
|
25
|
+
expect(described_class.new(all_locales).report)
|
26
|
+
.to eq(
|
27
|
+
<<~OUTPUT.chomp
|
28
|
+
\e[31m[ERROR]\e[0m Undeclared locale file(s) detected for:
|
29
|
+
|
30
|
+
cy
|
31
|
+
|
32
|
+
\e[1mEither declare these locale files or remove them from your locale files directory.\e[22m
|
33
|
+
OUTPUT
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when there aren't undeclared locales" do
|
39
|
+
before do
|
40
|
+
I18n.available_locales = [:en, :cy]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "outputs nil" do
|
44
|
+
expect(described_class.new(all_locales).report)
|
45
|
+
.to be_nil
|
46
|
+
end
|
47
|
+
end
|
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.2.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: 2021-
|
11
|
+
date: 2021-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -164,9 +164,11 @@ files:
|
|
164
164
|
- lib/rails_translation_manager/locale_checker/base_checker.rb
|
165
165
|
- lib/rails_translation_manager/locale_checker/incompatible_plurals.rb
|
166
166
|
- lib/rails_translation_manager/locale_checker/locale_checker_helper.rb
|
167
|
+
- lib/rails_translation_manager/locale_checker/missing_declared_locales.rb
|
167
168
|
- lib/rails_translation_manager/locale_checker/missing_english_locales.rb
|
168
169
|
- lib/rails_translation_manager/locale_checker/missing_foreign_locales.rb
|
169
170
|
- lib/rails_translation_manager/locale_checker/plural_forms.rb
|
171
|
+
- lib/rails_translation_manager/locale_checker/undeclared_locale_files.rb
|
170
172
|
- lib/rails_translation_manager/railtie.rb
|
171
173
|
- lib/rails_translation_manager/version.rb
|
172
174
|
- lib/rails_translation_manager/yaml_writer.rb
|
@@ -185,9 +187,11 @@ files:
|
|
185
187
|
- spec/rails_translation_manager/locale_checker/all_locales_spec.rb
|
186
188
|
- spec/rails_translation_manager/locale_checker/incompatible_plurals_spec.rb
|
187
189
|
- spec/rails_translation_manager/locale_checker/locale_checker_helper_spec.rb
|
190
|
+
- spec/rails_translation_manager/locale_checker/missing_declared_locales_spec.rb
|
188
191
|
- spec/rails_translation_manager/locale_checker/missing_english_locales_spec.rb
|
189
192
|
- spec/rails_translation_manager/locale_checker/missing_foreign_locales_spec.rb
|
190
193
|
- spec/rails_translation_manager/locale_checker/plural_forms_spec.rb
|
194
|
+
- spec/rails_translation_manager/locale_checker/undeclared_locale_files_spec.rb
|
191
195
|
- spec/rails_translation_manager/locale_checker_spec.rb
|
192
196
|
- spec/spec_helper.rb
|
193
197
|
- spec/support/tasks.rb
|
@@ -233,9 +237,11 @@ test_files:
|
|
233
237
|
- spec/rails_translation_manager/locale_checker/all_locales_spec.rb
|
234
238
|
- spec/rails_translation_manager/locale_checker/incompatible_plurals_spec.rb
|
235
239
|
- spec/rails_translation_manager/locale_checker/locale_checker_helper_spec.rb
|
240
|
+
- spec/rails_translation_manager/locale_checker/missing_declared_locales_spec.rb
|
236
241
|
- spec/rails_translation_manager/locale_checker/missing_english_locales_spec.rb
|
237
242
|
- spec/rails_translation_manager/locale_checker/missing_foreign_locales_spec.rb
|
238
243
|
- spec/rails_translation_manager/locale_checker/plural_forms_spec.rb
|
244
|
+
- spec/rails_translation_manager/locale_checker/undeclared_locale_files_spec.rb
|
239
245
|
- spec/rails_translation_manager/locale_checker_spec.rb
|
240
246
|
- spec/spec_helper.rb
|
241
247
|
- spec/support/tasks.rb
|