1
0
Fork 0
forked from OpenNeo/impress

i18n for outfits#index - plus the translate_with_links helper, which can be used for refactoring other stuff

This commit is contained in:
Emi Matchu 2013-01-04 18:58:25 -05:00
parent 5eb7842e36
commit cd323cbf53
3 changed files with 49 additions and 16 deletions

View file

@ -162,6 +162,32 @@ module ApplicationHelper
content_for :title, value
end
def translate_with_links(key, options={})
nonlink_options = {}
link_urls = {}
options.each do |key, value|
str_key = key.to_s
if str_key.end_with? '_link_url'
link_key = str_key[0..-5] # "abcdef_link_url" => "abcdef_link"
link_urls[link_key] = value
else
nonlink_options[key] = value
end
end
link_options = {}
link_urls.each do |link_key, url|
content = translate("#{key}.#{link_key}_content", nonlink_options)
link_options[link_key.to_sym] = link_to(content, url)
end
converted_options = link_options.merge(nonlink_options)
translate("#{key}.main_html", converted_options)
end
alias_method :twl, :translate_with_links
def userbar_contributions_summary(user)
contributions_link_content = translate('.userbar.contributions_link_content',
:user_points => user.points)

View file

@ -1,22 +1,11 @@
- title 'Your outfits'
%p
These are the outfits that you've saved to Dress to Impress so far. To save
some more, head to the wardrobe and click Save Outfit in the top right
corner.
%p
The link for each outfit is totally public, so please feel free to share the
URL with the whole wide world.
- title t('.title')
- unless @outfits.empty?
%p= t '.intro.saving'
%p= t '.intro.linking'
%ul#outfits= render @outfits
- else
%p
You haven't saved any outfits yet.
- succeed ',' do
= link_to 'Start at the home page', root_path
enter a pet name or choose a color combination, create the outfit of your
dreams, and click "Save Outfit" in the top right corner.
%p
It'll be fantastic. Promise.
%p= twl '.no_outfits', :start_link_url => root_path
- content_for :javascripts do
= include_javascript_libraries :jquery

View file

@ -442,6 +442,24 @@ en:
destroy:
success: Outfit "%{outfit_name}" successfully deleted.
index:
title: Your Outfits
intro:
saving:
These are the outfits that you've saved to Dress to Impress so far.
When you design an outfit you like, click Save Outfit in the top
right corner and it'll appear in this list.
linking:
The link for each outfit is totally public, so feel free to share
them with the world.
no_outfits:
main_html:
You haven't saved any outfits yet. %{start_link}, enter a pet's name
or choose a color combination, create the outfit of your dreams, and
click "Save Outfit" in the top right corner. It'll be great, I
promise.
start_link_content: Start at the home page
new:
tagline: Neopets wearables made easy!
load_pet_legend: Enter your pet's name