From 688b40830843e15d167dbbeccb65f346af706376 Mon Sep 17 00:00:00 2001 From: Erik Michaels-Ober Date: Thu, 15 Sep 2011 14:02:16 -0700 Subject: [PATCH] Begin refactoring to allow Adopt-a-Whatever --- app/controllers/addresses_controller.rb | 2 +- app/controllers/hydrants_controller.rb | 2 +- app/views/hydrants/_abandon.html.haml | 2 +- app/views/hydrants/_steal.html.haml | 2 +- app/views/hydrants/adopt.html.haml | 4 ++-- app/views/layouts/application.html.haml | 2 +- app/views/main/index.html.haml | 6 +++--- app/views/sessions/new.html.haml | 2 +- app/views/users/profile.html.haml | 2 +- app/views/users/thank_you.html.haml | 2 +- config/locales/en.yml | 23 ++++++++++++----------- test/functional/main_controller_test.rb | 2 +- 12 files changed, 26 insertions(+), 25 deletions(-) diff --git a/app/controllers/addresses_controller.rb b/app/controllers/addresses_controller.rb index e4abfb6..0d12c06 100644 --- a/app/controllers/addresses_controller.rb +++ b/app/controllers/addresses_controller.rb @@ -6,7 +6,7 @@ class AddressesController < ApplicationController unless @address.blank? respond_with @address else - render(:json => {"errors" => {"address" => [t("errors.address")]}}, :status => 404) + render(:json => {"errors" => {"address" => [t("errors.not_found", :thing => t("defaults.address"))]}}, :status => 404) end end end diff --git a/app/controllers/hydrants_controller.rb b/app/controllers/hydrants_controller.rb index 195e77d..a077689 100644 --- a/app/controllers/hydrants_controller.rb +++ b/app/controllers/hydrants_controller.rb @@ -6,7 +6,7 @@ class HydrantsController < ApplicationController unless @hydrants.blank? respond_with @hydrants else - render(:json => {"errors" => {"address" => [t("errors.hydrants")]}}, :status => 404) + render(:json => {"errors" => {"address" => [t("errors.not_found", :thing => t("defaults.thing"))]}}, :status => 404) end end diff --git a/app/views/hydrants/_abandon.html.haml b/app/views/hydrants/_abandon.html.haml index 2feb322..584278c 100644 --- a/app/views/hydrants/_abandon.html.haml +++ b/app/views/hydrants/_abandon.html.haml @@ -2,4 +2,4 @@ = f.hidden_field "id" = f.hidden_field "user_id", :value => "" = f.hidden_field "name", :value => "" - = f.submit t("buttons.abandon") + = f.submit t("buttons.abandon", :thing => t("defaults.thing")) diff --git a/app/views/hydrants/_steal.html.haml b/app/views/hydrants/_steal.html.haml index 24b85ff..7fc52b0 100644 --- a/app/views/hydrants/_steal.html.haml +++ b/app/views/hydrants/_steal.html.haml @@ -2,4 +2,4 @@ = f.hidden_field "id" = f.hidden_field "user_id", :value => "" = f.hidden_field "name", :value => "" - = f.submit t("buttons.steal") + = f.submit t("buttons.steal", :thing => t("buttons.thing")) diff --git a/app/views/hydrants/adopt.html.haml b/app/views/hydrants/adopt.html.haml index f3c4808..b36f254 100644 --- a/app/views/hydrants/adopt.html.haml +++ b/app/views/hydrants/adopt.html.haml @@ -1,9 +1,9 @@ = form_for :hydrant, :url => hydrants_path, :method => :put, :html => {:id => "adoption_form"} do |f| %h2 - = t("titles.adopt") + = t("titles.adopt", :thing => t("defaults.thing").titleize) = f.hidden_field "id" = f.hidden_field "user_id", :value => current_user.id - = f.label "name", t("labels.name_hydrant"), :id => "hydrant_name_label" + = f.label "name", t("labels.name_thing", :thing => t("defaults.thing")), :id => "hydrant_name_label" = f.text_field "name", :tabindex => 1 = f.submit t("buttons.adopt"), :tabindex => 2 = render :partial => 'users/edit_profile' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 286c42d..cd0e06e 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -2,7 +2,7 @@ %html %head %title - = t("titles.main") + = t("titles.main", :thing => t("defaults.thing").titleize) = stylesheet_link_tag "application" = javascript_include_tag "http://maps.google.com/maps/api/js?sensor=false" = javascript_include_tag "https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" diff --git a/app/views/main/index.html.haml b/app/views/main/index.html.haml index fb5e9fa..91159c9 100644 --- a/app/views/main/index.html.haml +++ b/app/views/main/index.html.haml @@ -1,6 +1,6 @@ #sidebar %h1 - = t("titles.main") + = t("titles.main", :thing => t("defaults.thing").titleize) %p#tagline = t("defaults.tagline") = form_for :address, :html => {:id => "address_form"} do |f| @@ -9,12 +9,12 @@ = label_tag "address", t("labels.address"), :id => "address_label" = text_field_tag "address", params[:address], :tabindex => 11 = hidden_field_tag "limit", params[:limit] || 20 - = submit_tag t("buttons.find"), :tabindex => 12 + = submit_tag t("buttons.find", :thing => t("defaults.thing").pluralize), :tabindex => 12 #logos = image_tag "logos/cfa.png", :alt => t("sponsors.cfa"), :title => t("sponsors.cfa") = image_tag "logos/boston.png", :alt => t("sponsors.city"), :title => t("sponsors.city") #feedback - %a{:href => "mailto:adoptahydrant@cityofboston.gov?subject=#{t("titles.main")} #{t("links.feedback")}"} + %a{:href => "mailto:adoptahydrant@cityofboston.gov?subject=#{t("titles.main", :thing => t("defaults.thing").titleize)} #{t("links.feedback")}"} = t("links.feedback") = image_tag "hydrant-in-snow.jpg", :id => "hydrant-in-snow" #map_canvas diff --git a/app/views/sessions/new.html.haml b/app/views/sessions/new.html.haml index ddf9042..64186d0 100644 --- a/app/views/sessions/new.html.haml +++ b/app/views/sessions/new.html.haml @@ -1,6 +1,6 @@ = form_for :user, :html => {:id => "combo_form"} do |f| %h2 - = t("titles.adopt") + = t("titles.adopt", :thing => t("defaults.thing").titleize) #common_fields = f.label "email", t("labels.email"), :id => "user_email_label" %em diff --git a/app/views/users/profile.html.haml b/app/views/users/profile.html.haml index 198cba8..80e118b 100644 --- a/app/views/users/profile.html.haml +++ b/app/views/users/profile.html.haml @@ -1,5 +1,5 @@ %h2 - = t("titles.adopted", :hydrant_name => @hydrant.name ? @hydrant.name.titleize : t("defaults.hydrant_name")) + = t("titles.adopted", :thing_name => @hydrant.name ? @hydrant.name.titleize : t("defaults.this_thing", :thing => t("defaults.thing"))) %br = t("titles.byline", :name => @hydrant.user.name) %br diff --git a/app/views/users/thank_you.html.haml b/app/views/users/thank_you.html.haml index a46947d..2a32670 100644 --- a/app/views/users/thank_you.html.haml +++ b/app/views/users/thank_you.html.haml @@ -1,5 +1,5 @@ %h2 - = t("titles.thank_you") + = t("titles.thank_you", :thing => t("defaults.thing")) = render :partial => 'hydrants/abandon' = render :partial => 'users/edit_profile' = render :partial => 'sessions/sign_out' diff --git a/config/locales/en.yml b/config/locales/en.yml index d2f2bb5..38c789a 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,18 +2,18 @@ en: buttons: - abandon: "Abandon this hydrant" + abandon: "Abandon this %{thing}" adopt: "Adopt!" back: "Back" change_password: "Change my password" edit_profile: "Edit profile" email_password: "Email me my password" - find: "Find fire hydrants" + find: "Find %{thing}" send_reminder: "Send reminder to shovel" sign_in: "Sign in" sign_out: "Sign out" sign_up: "Sign up" - steal: "Steal this hydrant" + steal: "Steal this %{thing}" update: "Update" captions: current_password: "(we need your current password to confirm your changes)" @@ -21,20 +21,21 @@ en: private: "(private)" public: "(may be visible to other users)" defaults: + address: "address" city: "Boston, MA" - hydrant_name: "This hydrant" + thing: "hydrant" + this_thing: "This %{thing}" tagline: "Claim responsibility for shoveling out a fire hydrant after it snows." tos: "By signing up, you agree to the %{tos}." errors: - address: "Could not find address." password: "You need to sign in or sign up before continuing." - hydrants: "Could not find hydrants." + not_found: "Could not find %{thing}." labels: address: "Address, Neighborhood" city_state: "City" email: "Email address" name: "Name" - name_hydrant: "Give this hydrant a name" + name_thing: "Give this %{thing} a name" organization: "Organization" password: "Password" password_choose: "Choose a password" @@ -50,13 +51,13 @@ en: forgot_password: "Forgot your password?" remembered_password: "Never mind. I remembered my password." titles: - adopt: "Adopt this Hydrant" - adopted: "%{hydrant_name} has been adopted" + adopt: "Adopt this %{thing}" + adopted: "%{thing_name} has been adopted" byline: "by %{name}" edit_profile: "Edit your Profile" - main: "Adopt a Hydrant" + main: "Adopt a %{thing}" ofline: "of %{organization}" - thank_you: "Thank you for adopting this hydrant!" + thank_you: "Thank you for adopting this %{thing}!" tos: "Terms of Service" sponsors: cfa: "Code for America" diff --git a/test/functional/main_controller_test.rb b/test/functional/main_controller_test.rb index 4a81ceb..78e9b5c 100644 --- a/test/functional/main_controller_test.rb +++ b/test/functional/main_controller_test.rb @@ -19,7 +19,7 @@ class MainControllerTest < ActionController::TestCase assert_select 'input#address', true assert_select 'input[name="commit"]' do assert_select '[type=?]', 'submit' - assert_select '[value=?]', 'Find fire hydrants' + assert_select '[value=?]', 'Find hydrants' end assert_select 'div#map_canvas', true end