Class: TidyI18n::DuplicateKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/tidy_i18n/duplicate_keys.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locale, locale_file_paths) ⇒ DuplicateKeys

Returns a new instance of DuplicateKeys.



9
10
11
12
# File 'lib/tidy_i18n/duplicate_keys.rb', line 9

def initialize(locale, locale_file_paths)
  self.locale = locale
  self.locale_file_paths = locale_file_paths
end

Instance Attribute Details

#localeObject

Returns the value of attribute locale.



7
8
9
# File 'lib/tidy_i18n/duplicate_keys.rb', line 7

def locale
  @locale
end

Instance Method Details

#allObject



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/tidy_i18n/duplicate_keys.rb', line 14

def all
  grouped_keys = translation_keys_for_current_locale.group_by(&:name).values
  grouped_keys.select do |occurrences|
    occurrences.count > 1
  end.collect do |occurrences|
    OpenStruct.new({
      :name => occurrences.first.name.sub(/^#{locale}\./, ""),
      :values => occurrences.collect(&:value)
    })
  end
end