Created
August 5, 2010 00:32
-
-
Save etozzato/509032 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Tag < ActiveRecord::Base | |
| attr_accessor :name | |
| def self.localized_tags(type) | |
| @localized_tags ||= {} | |
| @localized_tags[:tags] ||= find(:all, :select=> "`key`, 'name', `tag_type`") | |
| language = I18n.locale.to_sym | |
| if @localized_tags[language].nil? | |
| @localized_tags[language] ||= [] | |
| @localized_tags[:tags].each do |tag| | |
| next if tag.key =~ /inspired/ | |
| translated_tag = tag.dup | |
| translated_tag.name = I18n.t(tag.key.to_s.downcase.gsub(/\W/, '_')) | |
| next if translated_tag.name =~ /translation missing/ | |
| @localized_tags[language] << translated_tag | |
| end | |
| end | |
| @localized_tags[language].find_all{|t| t.tag_type == type} | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment