Sha256: dd10282d71e0b24550a5ccdbbff526b0d5c608d114b55e6e197afb891cb55557

Contents?: true

Size: 776 Bytes

Versions: 11

Compression:

Stored size: 776 Bytes

Contents

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

  class Translation < String
    class Attribute < Translation
      attr_accessor :requested_locale, :locale, :key
    end
    
    class Static < Translation
      attr_accessor :requested_locale, :locale, :key, :options, :plural_key, :original
      
      def initialize(string, meta = nil)
        self.original = string
        super
      end
    end
    
    def initialize(string, meta = nil)
      set_meta meta
      super string
    end
  
    def fallback?
      locale.to_sym != requested_locale.to_sym
    end
    
    def set_meta(meta)
      meta.each {|name, value| send :"#{name}=", value } if meta
    end
  end
end

Version data entries

11 entries across 11 versions & 4 rubygems

Version Path
kriss-gettext_i18n-0.2.0 vendor/globalize2/lib/globalize/translation.rb
kriss-gettext_i18n-0.2.1 vendor/globalize2/lib/globalize/translation.rb
kriss-gettext_i18n-0.2.2 vendor/globalize2/lib/globalize/translation.rb
kriss-gettext_i18n-0.2.3 vendor/globalize2/lib/globalize/translation.rb
simonmenke-globalize2-0.0.1 lib/globalize/translation.rb
simonmenke-globalize2-0.0.4 lib/globalize/translation.rb
simonmenke-globalize2-0.0.5 lib/globalize/translation.rb
simonmenke-globalize2-0.0.6 lib/globalize/translation.rb
simonmenke-simonmenke-globalize2-0.0.2 lib/globalize/translation.rb
simonmenke-globalize2-0.0.7 lib/globalize/translation.rb
globalize2-0.1.0 lib/globalize/translation.rb