Class: Rosette::Core::Translation
- Inherits:
-
Object
- Object
- Rosette::Core::Translation
- Includes:
- TranslationToHash
- Defined in:
- lib/rosette/core/extractor/translation.rb
Overview
Represents a translation. Translations always have an associated phrase, a locale, and some translated text.
Instance Attribute Summary collapse
-
#locale ⇒ String
readonly
The locale code.
-
#phrase ⇒ Phrase
readonly
The associated phrase object.
-
#translation ⇒ String
readonly
The translation text.
Class Method Summary collapse
-
.from_h(hash) ⇒ Hash
Turns this translation object into a hash.
Instance Method Summary collapse
-
#initialize(phrase, locale, translation) ⇒ Translation
constructor
Creates a new translation object.
Methods included from TranslationToHash
Constructor Details
#initialize(phrase, locale, translation) ⇒ Translation
Creates a new translation object.
25 26 27 28 29 |
# File 'lib/rosette/core/extractor/translation.rb', line 25 def initialize(phrase, locale, translation) @phrase = phrase @locale = locale @translation = translation end |
Instance Attribute Details
#locale ⇒ String (readonly)
Returns the locale code.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rosette/core/extractor/translation.rb', line 15 class Translation include TranslationToHash attr_reader :phrase, :locale, :translation # Creates a new translation object. # # @param [Phrase] phrase The associated phrase object. # @param [String] locale The locale code. # @param [String] translation The translated text. def initialize(phrase, locale, translation) @phrase = phrase @locale = locale @translation = translation end # Turns this translation object into a hash. # # @return [Hash] a hash with +phrase+ as a hash, +locale+, and # +translation+. def self.from_h(hash) new( Phrase.from_h(hash[:phrase]), hash[:locale], hash[:translation] ) end end |
#phrase ⇒ Phrase (readonly)
Returns the associated phrase object.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rosette/core/extractor/translation.rb', line 15 class Translation include TranslationToHash attr_reader :phrase, :locale, :translation # Creates a new translation object. # # @param [Phrase] phrase The associated phrase object. # @param [String] locale The locale code. # @param [String] translation The translated text. def initialize(phrase, locale, translation) @phrase = phrase @locale = locale @translation = translation end # Turns this translation object into a hash. # # @return [Hash] a hash with +phrase+ as a hash, +locale+, and # +translation+. def self.from_h(hash) new( Phrase.from_h(hash[:phrase]), hash[:locale], hash[:translation] ) end end |
#translation ⇒ String (readonly)
Returns the translation text.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rosette/core/extractor/translation.rb', line 15 class Translation include TranslationToHash attr_reader :phrase, :locale, :translation # Creates a new translation object. # # @param [Phrase] phrase The associated phrase object. # @param [String] locale The locale code. # @param [String] translation The translated text. def initialize(phrase, locale, translation) @phrase = phrase @locale = locale @translation = translation end # Turns this translation object into a hash. # # @return [Hash] a hash with +phrase+ as a hash, +locale+, and # +translation+. def self.from_h(hash) new( Phrase.from_h(hash[:phrase]), hash[:locale], hash[:translation] ) end end |