i18n_checker 0.6.1 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/i18n_checker/locale/file.rb +4 -0
- data/lib/i18n_checker/locale/files.rb +15 -1
- data/lib/i18n_checker/not_found/detector.rb +8 -6
- data/lib/i18n_checker/not_found/reporter/base.rb +1 -1
- data/lib/i18n_checker/not_found/reporter/default.rb +15 -11
- data/lib/i18n_checker/not_found/result.rb +12 -0
- data/lib/i18n_checker/not_found/text.rb +5 -4
- data/lib/i18n_checker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8cf8d2c4d52ae5db65c9b02ff730456919af4dc2
|
4
|
+
data.tar.gz: 8eb0e748d215970083af99f3c8755b64a32ea680
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf1bcd765372e888057dc05a236d5069c9b56709dbb2f66de6ec8792241d5f6c9e6a12d0f6030d1178ea40fb569271ed6ace9415240d5430e2238ea747d4a571
|
7
|
+
data.tar.gz: f1e78e8afeced6e32ac4f41bf36275444e9cbedd98076560bf03b5694600aa2c10c50e9b68b56a5e08b1c78de4eec986d1081f95dab65507232311a5348948c3
|
data/Gemfile.lock
CHANGED
@@ -7,7 +7,7 @@ module I18nChecker
|
|
7
7
|
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
-
def_delegators :locale_files, :size, :each
|
10
|
+
def_delegators :locale_files, :size, :each, :map
|
11
11
|
|
12
12
|
# Translation files for each language
|
13
13
|
#
|
@@ -27,6 +27,20 @@ module I18nChecker
|
|
27
27
|
self
|
28
28
|
end
|
29
29
|
|
30
|
+
def to_h
|
31
|
+
all_locale_texts = {}
|
32
|
+
locale_files.each do |locale_file|
|
33
|
+
lang = locale_file.lang.to_s
|
34
|
+
next all_locale_texts[lang] = nil if locale_file.empty?
|
35
|
+
all_locale_texts[lang] = {} if !all_locale_texts.key?(lang) || all_locale_texts[lang].nil?
|
36
|
+
locale_file.locale_texts.each do |k, v|
|
37
|
+
next if all_locale_texts[lang].key?(k)
|
38
|
+
all_locale_texts[lang][k] = v
|
39
|
+
end
|
40
|
+
end
|
41
|
+
all_locale_texts
|
42
|
+
end
|
43
|
+
|
30
44
|
private
|
31
45
|
|
32
46
|
attr_reader :locale_files
|
@@ -2,7 +2,7 @@ module I18nChecker
|
|
2
2
|
module NotFound
|
3
3
|
class Detector
|
4
4
|
def initialize(locale_files)
|
5
|
-
@
|
5
|
+
@locale_texts = locale_files.to_h
|
6
6
|
end
|
7
7
|
|
8
8
|
def detect(locale_texts)
|
@@ -13,12 +13,14 @@ module I18nChecker
|
|
13
13
|
private
|
14
14
|
|
15
15
|
def detect_not_found(locale_text)
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
not_founds = @locale_texts.select do |_lang, texts|
|
17
|
+
next false if texts.nil?
|
18
|
+
!texts.key?(locale_text.text)
|
19
|
+
end
|
20
|
+
not_founds.keys.map do |not_found_lang|
|
19
21
|
Text.new(
|
20
|
-
|
21
|
-
|
22
|
+
lang: not_found_lang.to_sym,
|
23
|
+
locale_text: locale_text
|
22
24
|
)
|
23
25
|
end
|
24
26
|
end
|
@@ -11,19 +11,23 @@ module I18nChecker
|
|
11
11
|
failed(result)
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
logger.info CHECK_COMPLETED.green
|
16
|
-
logger.info 'There was no translated text that can not be referenced'.green
|
17
|
-
end
|
14
|
+
private
|
18
15
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
16
|
+
def passed
|
17
|
+
logger.info CHECK_COMPLETED.green
|
18
|
+
logger.info 'There was no translated text that can not be referenced'.green
|
19
|
+
end
|
20
|
+
|
21
|
+
def failed(result)
|
22
|
+
logger.info CHECK_COMPLETED.red
|
23
|
+
logger.info "There are settings where translated text can not be found\n".red
|
24
|
+
result.each_file do |file, locale_texts|
|
25
|
+
logger.info file.cyan.to_s
|
26
|
+
locale_texts.each do |locale_text|
|
27
|
+
logger.info " line:#{locale_text.line}, column:#{locale_text.column} - #{locale_text.lang}.#{locale_text.text}"
|
28
|
+
end
|
29
|
+
end
|
25
30
|
end
|
26
|
-
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -10,6 +10,18 @@ module I18nChecker
|
|
10
10
|
def empty?
|
11
11
|
locale_texts.empty?
|
12
12
|
end
|
13
|
+
|
14
|
+
def each_file(&block)
|
15
|
+
file_texts = locale_texts.group_by(&:file)
|
16
|
+
file_texts.each do |file, texts|
|
17
|
+
texts.sort do |a, b|
|
18
|
+
lr = a.line <=> b.line
|
19
|
+
next lr if lr != 0
|
20
|
+
a.column <=> b.column
|
21
|
+
end
|
22
|
+
yield(file, texts)
|
23
|
+
end
|
24
|
+
end
|
13
25
|
end
|
14
26
|
end
|
15
27
|
end
|
@@ -5,17 +5,18 @@ module I18nChecker
|
|
5
5
|
class Text
|
6
6
|
extend Forwardable
|
7
7
|
|
8
|
-
|
8
|
+
attr_reader :lang
|
9
|
+
|
9
10
|
def_delegators :locale_text, :file, :line, :column, :text
|
10
11
|
|
11
|
-
def initialize(
|
12
|
+
def initialize(lang:, locale_text:)
|
13
|
+
@lang = lang
|
12
14
|
@locale_text = locale_text
|
13
|
-
@locale_file = locale_file
|
14
15
|
end
|
15
16
|
|
16
17
|
private
|
17
18
|
|
18
|
-
attr_reader :
|
19
|
+
attr_reader :locale_text
|
19
20
|
end
|
20
21
|
end
|
21
22
|
end
|
data/lib/i18n_checker/version.rb
CHANGED