1
0
Fork 0
forked from OpenNeo/impress

i18n for neopets_pages#create (flashes - holy snap, that was nasty)

This commit is contained in:
Emi Matchu 2013-01-01 23:40:37 -05:00
parent 4c6b43028b
commit c5e92ec53c
3 changed files with 103 additions and 23 deletions

View file

@ -10,40 +10,48 @@ class NeopetsPagesController < ApplicationController
@neopets_page.index = @page_params[:index] @neopets_page.index = @page_params[:index]
@neopets_page.source = @page_params[:source] @neopets_page.source = @page_params[:source]
saved_counts = @neopets_page.save_hangers! messages = [t('neopets_pages.create.success',
:index => @neopets_page.index)]
saved_counts = @neopets_page.save_hangers!
any_created = saved_counts[:created] > 0 any_created = saved_counts[:created] > 0
any_updated = saved_counts[:updated] > 0 any_updated = saved_counts[:updated] > 0
if any_created || any_updated if any_created && any_updated
message = "Page #{@neopets_page.index} saved! We " created_msg = t('neopets_pages.create.created_and_updated_hangers.created_msg',
message << "added " + pluralize(saved_counts[:created], 'item') + " to the items you own" if any_created :count => saved_counts[:created])
message << " and " if any_created && any_updated updated_msg = t('neopets_pages.create.created_and_updated_hangers.updated_msg',
message << "updated the count on " + pluralize(saved_counts[:updated], 'item') if any_updated :count => saved_counts[:updated])
message << ". " messages << t('neopets_pages.create.created_and_updated_hangers.text',
elsif @neopets_page.hangers.size > 1 :created_msg => created_msg,
message = "Success! We checked that page, and we already had all this data recorded. " :updated_msg => updated_msg)
else elsif any_created
message = "Success! We checked that page, and there were no wearables to add. " messages << t('neopets_pages.create.created_hangers',
:count => saved_counts[:created])
elsif any_updated
messages << t('neopets_pages.create.updated_hangers',
:count => saved_counts[:updated])
elsif @neopets_page.hangers.size > 1 # saw items, but at same quantities
messages << t('neopets_pages.create.no_changes')
else # no items recognized
messages << t('neopets_pages.create.no_data')
end end
unless @neopets_page.unknown_item_names.empty? unless @neopets_page.unknown_item_names.empty?
message << "We also found " + messages << t('neopets_pages.create.unknown_items',
pluralize(@neopets_page.unknown_item_names.size, 'item') + :item_names => @neopets_page.unknown_item_names.to_sentence,
" we didn't recognize: " + :count => @neopets_page.unknown_item_names.size)
@neopets_page.unknown_item_names.to_sentence +
". Please put each item on your pet and type its name in on the " +
"home page so we can have a record of it. Thanks! "
end end
if @neopets_page.last? if @neopets_page.last?
message << "That was the last page of your Neopets #{@neopets_page.name}." messages << t('neopets_pages.create.done', :name => @neopets_page.name)
destination = user_closet_hangers_path(current_user) destination = user_closet_hangers_path(current_user)
else else
message << "Now the frame should contain page #{@neopets_page.index + 1}. Paste that source code over, too." messages << t('neopets_pages.create.next_page',
:next_index => (@neopets_page.index + 1))
destination = {:action => :new, :index => (@neopets_page.index + 1)} destination = {:action => :new, :index => (@neopets_page.index + 1)}
end end
flash[:success] = message flash[:success] = messages.join(' ')
redirect_to destination redirect_to destination
else else
redirect_to :action => :new redirect_to :action => :new
@ -70,9 +78,7 @@ class NeopetsPagesController < ApplicationController
def on_parse_error(e) def on_parse_error(e)
Rails.logger.info "Neopets page parse error: #{e.message}" Rails.logger.info "Neopets page parse error: #{e.message}"
flash[:alert] = "We had trouble reading your source code. Is it a valid " + flash[:alert] = t('neopets_pages.create.parse_error')
"HTML document? Make sure you pasted the computery-looking result of " +
"clicking View Frame Source, and not the pretty page itself. "
render :action => :new render :action => :new
end end
end end

View file

@ -277,6 +277,43 @@ en-meep:
swf_assets_not_found_modeling_link_content: meep it for us swf_assets_not_found_modeling_link_content: meep it for us
neopets_pages: neopets_pages:
create:
success: Page %{index} meeped!
created_and_updated_hangers:
text: "%{created_msg} meep %{updated_msg}."
created_msg:
one: We added 1 meepit
other: We added %{count} meepit
updated_msg:
one: updated the meepity for 1 more
other: updated the meepity for %{count} more
created_hangers:
one: We added 1 new meepit to the list of meepits you own.
other: We added %{count} new meepits to the list of meepits you own.
updated_hangers:
one: We updated the quantity for 1 of your meepits.
other: We updated the quantity for %{count} of your meepits.
no_changes:
We already had this data meeped to your account,
so we didn't meep any changes.
no_data: We didn't meep any wearables, so we didn't meep any changes.
unknown_items:
one:
"We also meeped an item we didn't recognize: %{item_names}. Please
meep it for us and we'll update our database instantly. Thanks!"
other:
"We also meeped %{count} items we didn't recognize: %{item_names}.
Please meep them for us and we'll update our database instantly.
Thanks!"
next_page:
Now the frame should contain page %{next_index}.
Meep that source code over, too.
done: That was the last meepit of your Neopets %{name}.
parse_error:
We had trouble meeping your source code. Is it a valid HTML document?
Make sure you meeped the computery-looking result of clicking View
Frame Source, and not the pretty-looking page itself.
names: names:
closet: meepit closet: meepit
safety_deposit: safety demeepit safety_deposit: safety demeepit

View file

@ -278,9 +278,46 @@ en:
swf_assets_not_found_modeling_link_content: model it for us swf_assets_not_found_modeling_link_content: model it for us
neopets_pages: neopets_pages:
create:
success: Page %{index} saved!
created_and_updated_hangers:
text: "%{created_msg} and %{updated_msg}."
created_msg:
one: We added 1 item
other: We added %{count} items
updated_msg:
one: updated the quantity for 1 more
other: updated the quantity for %{count} more
created_hangers:
one: We added 1 new item to the list of items you own.
other: We added %{count} new items to the list of items you own.
updated_hangers:
one: We updated the quantity for 1 of your items.
other: We updated the quantity for %{count} of your items.
no_changes:
We already had this data recorded to your account, so we didn't make any changes.
no_data: We didn't see any wearables, so we didn't make any changes.
unknown_items:
one:
"We also found an item we didn't recognize: %{item_names}. Please
model it for us and we'll update our database instantly. Thanks!"
other:
"We also found %{count} items we didn't recognize: %{item_names}.
Please model them for us and we'll update our database instantly.
Thanks!"
next_page:
Now the frame should contain page %{next_index}.
Paste that source code over, too.
done: That was the last page of your Neopets %{name}.
parse_error:
We had trouble reading your source code. Is it a valid HTML document?
Make sure you pasted the computery-looking result of clicking View
Frame Source, and not the pretty-looking page itself.
names: names:
closet: closet closet: closet
safety_deposit: safety deposit safety_deposit: safety deposit
new: new:
title: Import from %{name}, Page %{index} title: Import from %{name}, Page %{index}
your_items_link: Back to Your Items your_items_link: Back to Your Items