Sha256: 9b4d72d9fd712739ff054c6a198956ba3d1256d42102c96e2e7d948cee34d0de

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# -*- encoding : utf-8 -*-

require 'active_support/all'
require 'colorize'

module Phrase
  autoload :Config, 'phrase/config'
  
  CLIENT_VERSION = "0.1"
  API_VERSION = "v1"
  
  class << self
    
    def config
      Thread.current[:phrase_config] ||= Phrase::Config.new
    end
    
    def config=(value)
      Thread.current[:phrase_config] = value
    end
    
    %w(enabled backend prefix suffix auth_token client_version js_host js_use_ssl cache_key_segments_initial cache_lifetime).each do |method|
      module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1
        def #{method}
          config.#{method}
        end
      DELEGATORS
    
      module_eval <<-DELEGATORS, __FILE__, __LINE__ + 1
        def #{method}=(value)
          config.#{method} = (value)
        end
      DELEGATORS
    end
    
    def enabled?
      enabled
    end
    
    def disabled?
      !enabled
    end
  end
  
  autoload :ViewHelpers, 'phrase/view_helpers'
  
  require 'phrase/version'
  require 'phrase/engine'
  require 'phrase/backend'
end

module I18n
  class << self
    def translate_with_phrase(*args)
      Phrase.backend.translate(*args)
    end
    alias_method_chain :translate, :phrase
    alias_method :t, :translate
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
phrase-0.3.1 lib/phrase.rb
phrase-0.3.0 lib/phrase.rb