module ApplicationHelper def translation_links(object, field) html = '' return html if RAILS_ENV == 'test' for l in %w(en fr de es) if l == Globalize::Locale.base_language.code done = true lang = Globalize::Locale.base_language else lang = Globalize::Language.pick(l) done = translation_available_for(object, field, lang) end img = image_tag("flags/#{l}.png", :title => "Switch to #{lang.english_name} #{done ? '(done)':'(not translated)'}", :alt => lang.english_name, :class => done ? 'done' : 'todo') html << link_to(img, params.merge(:locale => l)) end "#{html}" end def translation_available_for(object, field, lang) Globalize::ModelTranslation.find(:first, :conditions => ['table_name = ? AND facet = ? AND language_id = ?', object.tableize, field, lang.id]) end end