Module: Rosette::Core::TranslationToHash

Included in:
Translation
Defined in:
lib/rosette/core/extractor/translation/translation_to_hash.rb

Overview

Turns a Translation into a hash. Must be mixed into a Translation-like class.

Examples:

t = Translation.new
t.translation = 'foó'
t.locale = 'fr-FR'
t.phrase = Phrase.new

t.to_h  # => { translation: 'foó', locale: 'fr-FR', phrase: { ... } }

Instance Method Summary collapse

Instance Method Details

#to_hHash

Converts the attributes of a Rosette::Core::Translation into a hash of attributes. This includes the attributes of the associated Phrase object, which is also converted to a hash via the PhraseToHash module.

Returns:

  • (Hash)

    a hash of translation attributes.


22
23
24
# File 'lib/rosette/core/extractor/translation/translation_to_hash.rb', line 22

def to_h
  { locale: locale, translation: translation, phrase: phrase.to_h }
end