diff --git a/app/models/media.rb b/app/models/media.rb index 5aa0081185b..851fcb1bdf0 100644 --- a/app/models/media.rb +++ b/app/models/media.rb @@ -8,6 +8,10 @@ def child_types ['Fandom'] end + def translation_key + name.parameterize(separator: "_") + end + # The media tag for unwrangled fandoms def self.uncategorized tag = self.find_or_create_by_name(ArchiveConfig.MEDIA_UNCATEGORIZED_NAME) diff --git a/app/views/home/_fandoms.html.erb b/app/views/home/_fandoms.html.erb index f5cd74ef2e7..8a92a8a8a2c 100644 --- a/app/views/home/_fandoms.html.erb +++ b/app/views/home/_fandoms.html.erb @@ -3,7 +3,7 @@ <% cache "homepage-fandoms-version1", skip_digest: true do %> <% Media.for_menu.each do |medium| %> <% unless medium.id.nil? %> -
  • <%= link_to ts("#{medium.name}"), medium_fandoms_path(medium) %>
  • +
  • <%= link_to t(".#{medium.translation_key}"), medium_fandoms_path(medium) %>
  • <% end %> <% end %> <% end %> diff --git a/config/locales/views/en.yml b/config/locales/views/en.yml index 69b2975528d..6efd7e5d338 100644 --- a/config/locales/views/en.yml +++ b/config/locales/views/en.yml @@ -431,6 +431,16 @@ en: page_title: Donate or Volunteer fandoms: all_fandoms: All Fandoms + anime_manga: Anime & Manga + books_literature: Books & Literature + cartoons_comics: Cartoons & Comics + movies: Movies + music_bands: Music & Bands + other_media: Other Media + real_people_celebrities: Real People & Celebrities + tv_shows: TV Shows + uncategorized_fandoms: Uncategorized Fandoms + video_games: Video Games index: browse_or_favorite: one: Browse fandoms by media or favorite up to %{count} tag to have it listed here! diff --git a/spec/models/media_spec.rb b/spec/models/media_spec.rb new file mode 100644 index 00000000000..f36a178b067 --- /dev/null +++ b/spec/models/media_spec.rb @@ -0,0 +1,10 @@ +require "spec_helper" + +describe Media do + describe "#translation_key" do + it "returns a parameterized version of the media name using underscore as a separator" do + media = create(:media, name: "Widgets; Tools & Doodads") + expect(media.translation_key).to eql("widgets_tools_doodads") + end + end +end