Class: MiradorRails::Locale
- Inherits:
-
Object
- Object
- MiradorRails::Locale
- Defined in:
- lib/mirador_rails/locale.rb
Instance Attribute Summary collapse
-
#language ⇒ Object
readonly
Returns the value of attribute language.
Instance Method Summary collapse
- #file ⇒ Object
- #file_source ⇒ Object
-
#initialize(language) ⇒ Locale
constructor
A new instance of Locale.
- #path ⇒ Object
Constructor Details
#initialize(language) ⇒ Locale
Returns a new instance of Locale.
5 6 7 |
# File 'lib/mirador_rails/locale.rb', line 5 def initialize(language) @language = language end |
Instance Attribute Details
#language ⇒ Object (readonly)
Returns the value of attribute language.
3 4 5 |
# File 'lib/mirador_rails/locale.rb', line 3 def language @language end |
Instance Method Details
#file ⇒ Object
18 19 20 21 22 |
# 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 ⇒ Object
13 14 15 16 |
# 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 ⇒ Object
9 10 11 |
# File 'lib/mirador_rails/locale.rb', line 9 def path "#{language}/translation.json" end |