Sha256: f26fa9c3a85903f0cb9119b7190867df969feafe2749babf4f289d6369455d7b

Contents?: true

Size: 1.07 KB

Versions: 2

Compression:

Stored size: 1.07 KB

Contents

=begin
  locale_rails/lib/action_view.rb - Ruby/Locale for "Ruby on Rails"

  Copyright (C) 2008  Masao Mutoh

  You may redistribute it and/or modify it under the same
  license terms as Ruby.

  Original: Ruby-GetText-Package-1.92.0

=end

require 'action_view'

module ActionView #:nodoc:
   class PathSet < Array

     def find_template_with_locale_rails(original_template_path, format = nil, html_fallback = true)
      return original_template_path if original_template_path.respond_to?(:render)

      path = original_template_path.sub(/^\//, '')
      if m = path.match(/(.*)\.(\w+)$/)
        template_file_name, template_file_extension = m[1], m[2]
      else
        template_file_name = path
      end
 
      Locale.candidates.each do |v|
        file_name = "#{template_file_name}_#{v}"
	begin
          return find_template_without_locale_rails(file_name, format, false)
        rescue MissingTemplate => e
	end
      end
      find_template_without_locale_rails(original_template_path, format, html_fallback)
    end
    alias_method_chain :find_template, :locale_rails

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
locale_rails-2.0.2 lib/locale_rails/action_view.rb
locale_rails-2.0.3 lib/locale_rails/action_view.rb