Revision: 37271
Updated Code
at December 7, 2010 17:34 by insanedreamer
Updated Code
module ActionView module Helpers #:nodoc: module AssetTagHelper def image_path(source) if File.exists? [RAILS_ROOT, 'public', 'images', I18n.locale, source].join('/') compute_public_path(source, "images/#{I18n.locale}") elsif File.exists? [RAILS_ROOT, 'public', 'images', I18n.default_locale, source].join('/') compute_public_path(source, "images/#{I18n.default_locale}") else compute_public_path(source, 'images') end end alias_method :path_to_image, :image_path end end end
Revision: 37270
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at December 7, 2010 17:29 by insanedreamer
Initial Code
module ActionView module Helpers #:nodoc: module AssetTagHelper def image_path(source) if File.exists? [RAILS_ROOT, 'public', 'images', I18n.locale, source].join('/') compute_public_path(source, "images/#{I18n.locale}") else compute_public_path(source, 'images') end end alias_method :path_to_image, :image_path end end end
Initial URL
Initial Description
Patches Rails 3 to automatically look for images in a folder corresponding to the current locale (under 'images', ie: '/images/en'), and falling back first to the folder of the default_locale, and then to the main images folder ('/images') if the image was not found in the locale folder. Put any localized images in their corresponding folders ('/images/en', '/images/es', etc.) and any non-localized images in '/images'. No need to specify anything special in the view, just use image_tag as usual.
Initial Title
Automagically find localized images
Initial Tags
Initial Language
Rails