Class: Globalize::Translation

Inherits:
String
  • Object
show all
Defined in:
lib/globalize/translation.rb

Overview

Translations are simple value objects that carry some context information alongside the actual translation string.

Direct Known Subclasses

Attribute, Static

Defined Under Namespace

Classes: Attribute, Static

Instance Method Summary collapse

Constructor Details

#initialize(string, meta = nil) ⇒ Translation

Returns a new instance of Translation.



19
20
21
22
# File 'lib/globalize/translation.rb', line 19

def initialize(string, meta = nil)
  set_meta meta
  super string
end

Instance Method Details

#fallback?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/globalize/translation.rb', line 24

def fallback?
  locale.to_sym != requested_locale.to_sym
end

#set_meta(meta) ⇒ Object



28
29
30
# File 'lib/globalize/translation.rb', line 28

def set_meta(meta)
  meta.each {|name, value| send :"#{name}=", value } if meta
end