Module: LocaleCheckerHelper

Included in:
IncompatiblePlurals, MissingDeclaredLocales, MissingEnglishLocales, MissingForeignLocales, UndeclaredLocaleFiles
Defined in:
lib/rails_translation_manager/locale_checker/locale_checker_helper.rb

Constant Summary collapse

PLURAL_KEYS =
%w[zero one two few many other].freeze

Instance Method Summary collapse

Instance Method Details

#english_keys_excluding_plurals(all_locales) ⇒ Object



16
17
18
# File 'lib/rails_translation_manager/locale_checker/locale_checker_helper.rb', line 16

def english_keys_excluding_plurals(all_locales)
  exclude_plurals(all_locales.find { |locale| locale[:locale] == :en }[:keys])
end

#exclude_plurals(keys) ⇒ Object



6
7
8
# File 'lib/rails_translation_manager/locale_checker/locale_checker_helper.rb', line 6

def exclude_plurals(keys)
  keys.reject { |key| key_is_plural?(key) }
end

#group_keys(locales) ⇒ Object



10
11
12
13
14
# File 'lib/rails_translation_manager/locale_checker/locale_checker_helper.rb', line 10

def group_keys(locales)
  locales.keys.group_by do |key|
    locales[key]
  end
end

#key_is_plural?(key) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/rails_translation_manager/locale_checker/locale_checker_helper.rb', line 20

def key_is_plural?(key)
  PLURAL_KEYS.include?(key.split(".").last)
end