class FastGettext::TranslationRepository::Mo

Responsibility:

- find and store mo files
- provide access to translations in mo files

Constants

CONTEXT_SEPARATOR

Public Class Methods

new(name, options = {}) click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 12
def initialize(name, options = {})
  super
  @eager_load = options.fetch(:eager_load, false)
  reload
end

Public Instance Methods

all_translations() click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 31
def all_translations
  current_translations.data
end
available_locales() click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 18
def available_locales
  @files.keys
end
pluralisation_rule() click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 22
def pluralisation_rule
  current_translations.pluralisation_rule
end
reload() click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 26
def reload
  find_and_store_files(@name, @options)
  super
end

Protected Instance Methods

current_translations() click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 44
def current_translations
  @files[FastGettext.locale] || MoFile.empty
end
find_and_store_files(name, options) click to toggle source
# File lib/fast_gettext/translation_repository/mo.rb, line 37
def find_and_store_files(name, options)
  # parse all .mo files with the right name, that sit in locale/LC_MESSAGES folders
  find_files_in_locale_folders(File.join('LC_MESSAGES', "#{name}.mo"), options[:path]) do |_locale, file|
    MoFile.new(file, eager_load: @eager_load)
  end
end