Class: TidyI18n::DuplicateKeys
- Inherits:
-
Object
- Object
- TidyI18n::DuplicateKeys
- Defined in:
- lib/tidy_i18n/duplicate_keys.rb
Instance Attribute Summary collapse
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
Instance Method Summary collapse
- #all ⇒ Object
-
#initialize(locale, locale_file_paths) ⇒ DuplicateKeys
constructor
A new instance of DuplicateKeys.
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
#locale ⇒ Object
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
#all ⇒ Object
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 |