Sha256: 9da18faf81962173d364727dcbb3478f52a7fa7fadcdb52725bd386abf01b0cc

Contents?: true

Size: 898 Bytes

Versions: 1

Compression:

Stored size: 898 Bytes

Contents

module I18nViz
  module ViewHelpers

    def translate(key, options = {}) # TODO: alias
      if display_i18n_viz? && options[:i18n_viz] != false
        # TODO: ActionController::Base.perform_caching = false  if ActionController::Base.perform_caching == true
        if !options[:scope].blank? 
          "#{super(key, options)}--#{options[:scope].to_s}.#{key}--"
        else
          "#{super(key, options)}--#{key}--"
        end
      else
        super(key, options)
      end
    end
    alias :t :translate
    
    def i18n_viz_include_tag # TODO: doesn't work yet
      return unless display_i18n_viz?
      
      stylesheet_link_tag("i18n_viz")
      javascript_include_tag "i18n_viz"
    end

    def display_i18n_viz?
      I18nViz.enabled? && params && params[:i18n_viz]  rescue false  # rescue workaround, because params is weirdly defined in e.g. ActionMailer 
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
i18n_viz-0.4.0 lib/i18n_viz/view_helpers.rb