Class: ActionView::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gettext/rails.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#render_file_with_gettext(template_path, use_full_path = true, local_assigns = {}) ⇒ Object

This provides to find localized template files such as foo_ja.html.erb, foo_ja_JP.html.erb instead of foo.html.erb. If the file isn’t found, foo.html.erb is used.



276
277
278
279
280
281
282
283
284
285
# File 'lib/gettext/rails.rb', line 276

def render_file_with_gettext(template_path, use_full_path = true, local_assigns = {})
  locale = GetText.locale
  [locale.to_general, locale.to_s, locale.language, Locale.default.language].uniq.each do |v|
	localized_path = "#{template_path}_#{v}"
    if (respond_to? :file_exists?) ? file_exists?(localized_path) : (finder.file_exists? localized_path)
      return render_file_without_gettext(localized_path, use_full_path, local_assigns)
    end
  end
  render_file_without_gettext(template_path, use_full_path, local_assigns)
end