Class: LocaleFileChecker

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n/locale_file_checker.rb

Constant Summary collapse

TYPE_MISSING_INTERPOLATION_KEYS =
1
TYPE_UNSUPPORTED_INTERPOLATION_KEYS =
2
TYPE_MISSING_PLURAL_KEYS =
3
TYPE_INVALID_MESSAGE_FORMAT =
4
5

Instance Method Summary collapse

Instance Method Details

#check(locale) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/i18n/locale_file_checker.rb', line 13

def check(locale)
  @errors = {}
  @locale = locale.to_s

  locale_files.each do |locale_path|
    next unless reference_path = reference_file(locale_path)

    @relative_locale_path =
      Pathname.new(locale_path).relative_path_from(Pathname.new(Rails.root)).to_s
    @locale_yaml = YAML.load_file(locale_path, aliases: true)
    @reference_yaml = YAML.load_file(reference_path, aliases: true)

    next if @locale_yaml.blank? || @locale_yaml.first[1].blank?

    check_interpolation_keys
    check_plural_keys
    check_message_format
    check_markdown_links
  end

  @errors
end