Module: I18n::Validator
- Defined in:
- lib/i18n-validator.rb,
lib/i18n-validator/version.rb
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
-
.missing_locales(path) ⇒ Object
Presents a list of missing locale entries.
Class Method Details
.missing_locales(path) ⇒ Object
Presents a list of missing locale entries
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/i18n-validator.rb', line 9 def self.missing_locales(path) I18n.load_path << path # Fetch all keys per locale keys_per_locale = Hash[I18n.available_locales.map{ |locale| [ locale, I18n.translate('.', :locale => locale).map{ |key, value| self.convert_key_value_hash_to_array(key, value) }.flatten.sort ] }] if keys_per_locale.length <= 1 # there couldn't be any missing locales # when we only have 1 locale... [] else # Remap Hash to use values as keys locales_per_key = self.invert_key_value_hash(keys_per_locale) available_locales_length = I18n.available_locales.length locales_per_key.reject{ |key, locales| locales.length == available_locales_length }.sort{ |a,b| a[0] <=> b[0] }.map{ |key, locales| [key, (I18n.available_locales - locales).sort{ |a,b| a.to_s <=> b.to_s }] } end end |