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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c71d969ddf7b59a8c0082056dd1ee96a85db65b7
4
- data.tar.gz: 5b5f7a01a302e4085e8cedb8eea056af07e3209e
3
+ metadata.gz: 8cf8d2c4d52ae5db65c9b02ff730456919af4dc2
4
+ data.tar.gz: 8eb0e748d215970083af99f3c8755b64a32ea680
5
5
  SHA512:
6
- metadata.gz: 6661d556df7bb32254cff25183c9147f829543744a7f2ef9f23e15e8bec1c6574a0eca1ef68584aa2cd7a3241ad979153726fe8ed1e994b816b8ff4dd049f142
7
- data.tar.gz: e39fd221820bb1856006a939f1e9c93785f87e30ce659e7f619756bd9e7a4e99b5874372b84dd69bf893fcdcc0e910a694d0c20ee20112399d30807a0bfeb1fe
6
+ metadata.gz: bf1bcd765372e888057dc05a236d5069c9b56709dbb2f66de6ec8792241d5f6c9e6a12d0f6030d1178ea40fb569271ed6ace9415240d5430e2238ea747d4a571
7
+ data.tar.gz: f1e78e8afeced6e32ac4f41bf36275444e9cbedd98076560bf03b5694600aa2c10c50e9b68b56a5e08b1c78de4eec986d1081f95dab65507232311a5348948c3
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- i18n_checker (0.6.1)
4
+ i18n_checker (0.7.0)
5
5
  colorator (~> 1.1.0)
6
6
  haml_parser (~> 0.4)
7
7
  parser
@@ -67,6 +67,10 @@ module I18nChecker
67
67
  self
68
68
  end
69
69
 
70
+ def empty?
71
+ locale_texts.empty?
72
+ end
73
+
70
74
  private
71
75
 
72
76
  def compact_of(values = {}, path = KeyPath.new)
@@ -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
- @locale_files = locale_files
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
- locale_files = @locale_files.dup
17
- locale_files.delete_if { |locale_file| locale_file.include?(locale_text) }
18
- locale_files.map do |locale_file|
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
- locale_text: locale_text,
21
- locale_file: locale_file
22
+ lang: not_found_lang.to_sym,
23
+ locale_text: locale_text
22
24
  )
23
25
  end
24
26
  end
@@ -10,7 +10,7 @@ module I18nChecker
10
10
 
11
11
  private
12
12
 
13
- attr_reader :logger
13
+ attr_reader :logger
14
14
  end
15
15
  end
16
16
  end
@@ -11,19 +11,23 @@ module I18nChecker
11
11
  failed(result)
12
12
  end
13
13
 
14
- def passed
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
- def failed(result)
20
- logger.info CHECK_COMPLETED.red
21
- logger.info "There are settings where translated text can not be found\n".red
22
- result.locale_texts.each do |locale_text|
23
- logger.info locale_text.file.cyan.to_s
24
- logger.info " line:#{locale_text.line}, column:#{locale_text.column} - #{locale_text.lang}.#{locale_text.text}"
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
- def_delegators :locale_file, :lang
8
+ attr_reader :lang
9
+
9
10
  def_delegators :locale_text, :file, :line, :column, :text
10
11
 
11
- def initialize(locale_file:, locale_text:)
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 :locale_file, :locale_text
19
+ attr_reader :locale_text
19
20
  end
20
21
  end
21
22
  end
@@ -1,3 +1,3 @@
1
1
  module I18nChecker
2
- VERSION = '0.6.1'.freeze
2
+ VERSION = '0.7.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - holyshared