class MiradorRails::Locale

Attributes

language[R]

Public Class Methods

new(language) click to toggle source
# File lib/mirador_rails/locale.rb, line 5
def initialize(language)
  @language = language
end

Public Instance Methods

file() click to toggle source
# File lib/mirador_rails/locale.rb, line 18
def file
  # Rails.application.assets is `nil` in production mode (where compile assets is enabled).
  # This workaround is based off of this comment: https://github.com/fphilipe/premailer-rails/issues/145#issuecomment-225992564
  (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(path)
end
file_source() click to toggle source
# File lib/mirador_rails/locale.rb, line 13
def file_source
  raise MiradorRails::Exceptions::LocaleNotFound, "Could not find #{path}" if file.blank?
  file.source.force_encoding('UTF-8')
end
path() click to toggle source
# File lib/mirador_rails/locale.rb, line 9
def path
  "#{language}/translation.json"
end