Module: I18n::Backend::Vulgata::Implementation
Instance Method Summary collapse
- #initialize(store = {}) ⇒ Object
- #store_vulgata_translation(locale, key, value) ⇒ Object
- #translations ⇒ Object
- #vulgata_translate(locale, label, options = {}) ⇒ Object
- #vulgata_translations ⇒ Object
Instance Method Details
#initialize(store = {}) ⇒ Object
12 13 14 15 |
# File 'lib/i18n/backend/vulgata.rb', line 12 def initialize(store = {}) @vulgata_translations = store super() end |
#store_vulgata_translation(locale, key, value) ⇒ Object
17 18 19 |
# File 'lib/i18n/backend/vulgata.rb', line 17 def store_vulgata_translation(locale, key, value) @vulgata_translations[key(locale, key)] = value end |
#translations ⇒ Object
25 26 27 |
# File 'lib/i18n/backend/vulgata.rb', line 25 def translations super end |
#vulgata_translate(locale, label, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/i18n/backend/vulgata.rb', line 29 def vulgata_translate(locale, label, = {}) key = key(locale, label) entry = @vulgata_translations[key] # contains false value if source or no active record translation entry = label if entry == false if entry.nil? translation = ::Vulgata::I18nTranslation.find_by(locale: locale, key: label) if translation.present? entry = translation.value @vulgata_translations[key] = entry else # create a source translation - creates all the pending states ::Vulgata::I18nTranslation.find_or_create_by(locale: I18n.default_locale, key: label) do |new_translation| new_translation.value = label end @vulgata_translations[key] = (locale.to_sym == I18n.default_locale ? label : false) # false indicates translation is not available entry = label end end deep_interpolation = [:deep_interpolation] values = .except(*RESERVED_KEYS) if values entry = if deep_interpolation deep_interpolate(locale, entry, values) else interpolate(locale, entry, values) end end entry.html_safe end |
#vulgata_translations ⇒ Object
21 22 23 |
# File 'lib/i18n/backend/vulgata.rb', line 21 def vulgata_translations @vulgata_translations end |