Internationalize all strings

[Delivers #14154783]
This commit is contained in:
Erik Michaels-Ober 2011-09-14 16:50:39 -07:00
parent ad4aa27213
commit d253fbd34b
23 changed files with 122 additions and 62 deletions

View File

@ -7,6 +7,7 @@ gem 'devise'
gem 'geokit'
gem 'haml', '~> 3.2.0.alpha'
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
gem 'rack-contrib'
platforms :jruby do
gem 'jruby-openssl'

View File

@ -75,6 +75,8 @@ GEM
rack (1.3.2)
rack-cache (1.0.3)
rack (>= 0.4)
rack-contrib (1.1.0)
rack (>= 0.9.1)
rack-mount (0.8.3)
rack (>= 1.0.0)
rack-ssl (1.3.2)
@ -139,6 +141,7 @@ DEPENDENCIES
haml (~> 3.2.0.alpha)
jruby-openssl
pg
rack-contrib
rails (~> 3.1.0)
rails_admin!
simplecov

View File

@ -166,7 +166,7 @@ $(function() {
$('#user_forgot_password_link').click(function() {
$('#user_sign_in_fields').slideUp();
$('#user_forgot_password_fields').slideDown(function() {
$('#user_remembered_password').click(function() {
$('#user_remembered_password_link').click(function() {
$('#user_forgot_password_fields').slideUp();
$('#user_sign_in_fields').slideDown();
$('#combo_form').data('state', 'user_sign_in');

View File

@ -1,6 +1,7 @@
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :set_flash_from_params
before_filter :set_locale
protected
@ -11,4 +12,8 @@ protected
end
end
end
def set_locale
I18n.locale = env['rack.locale'] || I18n.default_locale
end
end

View File

@ -2,4 +2,4 @@
= f.hidden_field "id"
= f.hidden_field "user_id", :value => ""
= f.hidden_field "name", :value => ""
= f.submit "Abandon this hydrant"
= f.submit t("buttons.abandon")

View File

@ -1,3 +1,3 @@
= form_for :hydrants, :url => info_window_path, :html => {:id => "back_form", :method => "get"} do |f|
= f.hidden_field "id"
= f.submit "Back"
= f.submit t("buttons.back")

View File

@ -2,4 +2,4 @@
= f.hidden_field "id"
= f.hidden_field "user_id", :value => ""
= f.hidden_field "name", :value => ""
= f.submit "Steal this hydrant"
= f.submit t("buttons.steal")

View File

@ -1,13 +1,10 @@
= form_for :hydrant, :url => hydrants_path, :method => :put, :html => {:id => "adoption_form"} do |f|
%h2
Adopt this Hydrant
= t("titles.adopt")
= f.hidden_field "id"
= f.hidden_field "user_id", :value => current_user.id
= f.label "name", "Give this hydrant a name", :id => "hydrant_name_label"
= f.label "name", t("labels.name_hydrant"), :id => "hydrant_name_label"
= f.text_field "name", :tabindex => 1
= f.submit "Adopt!", :tabindex => 2
%p
By adopting this hydrant, you agree to the
= link_to("Terms of Service", tos_path, :tabindex => 3, :id => "tos_link") + "."
= f.submit t("buttons.adopt"), :tabindex => 2
= render :partial => 'users/edit_profile'
= render :partial => 'sessions/sign_out'

View File

@ -1,5 +1,5 @@
%h2
Terms of Service
= t("titles.tos")
%ol
%li
%h3

View File

@ -2,7 +2,7 @@
%html
%head
%title
Adopt a Hydrant
= t("titles.main")
= 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"

View File

@ -1,20 +1,20 @@
#sidebar
%h1
Adopt a Hydrant
= t("titles.main")
%p#tagline
Claim responsibility for shoveling out a fire hydrant after it snows.
= t("defaults.tagline")
= form_for :address, :html => {:id => "address_form"} do |f|
= label_tag "city_state", "City", :id => "city_state_label"
= select_tag "city_state", '<option value="Boston, MA" selected="selected">Boston, MA</option>'.html_safe, :tabindex => 10
= label_tag "address", "Address, Neighborhood", :id => "address_label"
= label_tag "city_state", t("labels.city_state"), :id => "city_state_label"
= select_tag "city_state", "<option value=\"#{t("defaults.city")}\" selected=\"selected\">#{t("defaults.city")}</option>".html_safe, :tabindex => 10
= 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 "Find fire hydrants", :tabindex => 12
= submit_tag t("buttons.find"), :tabindex => 12
#logos
= image_tag "logos/cfa.png", :alt => "Code for America", :title => "Code for America"
= image_tag "logos/boston.png", :alt => "City of Boston", :title => "City of Boston"
= 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=Adopt-a-Hydrant Feedback"}
Feedback
%a{:href => "mailto:adoptahydrant@cityofboston.gov?subject=#{t("titles.main")} #{t("links.feedback")}"}
= t("links.feedback")
= image_tag "hydrant-in-snow.jpg", :id => "hydrant-in-snow"
#map_canvas

View File

@ -1,7 +1,7 @@
= form_for resource, :as => resource_name, :url => password_path(resource_name), :html => {:id => "edit_form", :method => :put} do |f|
%h2
Edit your Profile
= t("titles.edit_profile")
= f.hidden_field "reset_password_token"
= f.label "password", "New password", :id => "user_password_label"
= f.label "password", t("labels.password_new"), :id => "user_password_label"
= f.password_field "password", :tabindex => 1
= f.submit "Change my password", :tabindex => 2
= f.submit t("buttons.change_password"), :tabindex => 2

View File

@ -1,2 +1,2 @@
= form_for :sign_in, :html => {:id => "sign_in_form"} do |f|
= f.submit "Sign in"
= f.submit t("buttons.sign_in")

View File

@ -1,2 +1,2 @@
= form_for :sign_out, :html => {:id => "sign_out_form"} do |f|
= f.submit "Sign out"
= f.submit t("buttons.sign_out")

View File

@ -1,34 +1,33 @@
= form_for :user, :html => {:id => "combo_form"} do |f|
%h2
Adopt this Hydrant
= t("titles.adopt")
#common_fields
= f.label "email", "Email address", :id => "user_email_label"
= f.label "email", t("labels.email"), :id => "user_email_label"
= f.text_field "email", :value => params[:user] ? params[:user][:email] : nil, :tabindex => 1
= f.label "new" , radio_button_tag("user", "new", true, :tabindex => 2).html_safe + "I haven't signed up yet"
= f.label "existing", radio_button_tag("user", "existing").html_safe + "I've already signed up"
= f.label "new" , radio_button_tag("user", "new", true, :tabindex => 2).html_safe + t("labels.user_new")
= f.label "existing", radio_button_tag("user", "existing").html_safe + t("labels.user_existing")
#user_sign_up_fields
= f.label "name", "Name", :id => "user_name_label"
= f.label "name", t("labels.name"), :id => "user_name_label"
= f.text_field "name", :tabindex => 3
= f.label "organization", "Organization", :id => "user_organization_label"
= f.label "organization", t("labels.organization"), :id => "user_organization_label"
= f.text_field "organization", :tabindex => 4
= f.label "voice_number", "Phone number", :id => "user_voice_number_label"
= f.label "voice_number", t("labels.voice_number"), :id => "user_voice_number_label"
= f.text_field "voice_number", :tabindex => 5
= f.label "sms_number", "SMS number", :id => "user_sms_number_label"
= f.label "sms_number", t("labels.sms_number"), :id => "user_sms_number_label"
= f.text_field "sms_number", :tabindex => 6
= f.label "password_confirmation", "Choose a password", :id => "user_password_confirmation_label"
= f.label "password_confirmation", t("labels.password_choose"), :id => "user_password_confirmation_label"
= f.password_field "password_confirmation", :tabindex => 7
= f.submit "Sign up", :tabindex => 8
= f.submit t("buttons.sign_up"), :tabindex => 8
%p
By signing up, you agree to the
= link_to("Terms of Service", tos_path, :tabindex => 9, :id => "tos_link") + "."
= t("defaults.tos", :tos => link_to(t("titles.tos"), tos_path, :tabindex => 3, :id => "tos_link")).html_safe
#user_sign_in_fields{:style => "display: none;"}
= f.label "password", "Password", :id => "user_password_label"
= f.label "password", t("labels.password"), :id => "user_password_label"
= f.password_field "password", :tabindex => 0
= f.label "remember_me", (f.check_box("remember_me", :checked => true, :tabindex => 0).html_safe + "Stay signed in"), :id => "user_remember_me_label"
= f.submit "Sign in", :tabindex => 0
= f.label "remember_me", (f.check_box("remember_me", :checked => true, :tabindex => 0).html_safe + t("labels.remember_me")), :id => "user_remember_me_label"
= f.submit t("buttons.sign_in"), :tabindex => 0
%p
= link_to "Forgot your password?", "#", :id => "user_forgot_password_link", :tabindex => 0
= link_to t("links.forgot_password"), "#", :id => "user_forgot_password_link", :tabindex => 0
#user_forgot_password_fields{:style => "display: none;"}
= f.submit "Email me my password", :tabindex => 0
= f.submit t("buttons.email_password"), :tabindex => 0
%p
= link_to "Never mind. I remembered my password.", "#", :id => "user_remembered_password", :tabindex => 0
= link_to t("links.remembered_password"), "#", :id => "user_remembered_password_link", :tabindex => 0

View File

@ -1,2 +1,2 @@
= form_for :user, :url => edit_user_registration_path, :html => {:id => "edit_profile_form", :method => "get"} do |f|
= f.submit "Edit profile"
= f.submit t("buttons.edit_profile")

View File

@ -2,4 +2,4 @@
= f.hidden_field "from_user_id", :value => current_user.id
= f.hidden_field "to_user_id", :value => @hydrant.user.id
= f.hidden_field "hydrant_id", :value => @hydrant.id
= f.submit "Send reminder to shovel"
= f.submit t("buttons.send_reminder")

View File

@ -1,24 +1,25 @@
= form_for resource, :as => resource_name, :url => registration_path(resource_name), :html => {:id => "edit_form", :method => :put} do |f|
%h2
Edit your Profile
= t("titles.edit_profile")
= f.hidden_field "id"
= f.label "email", "Email address", :id => "user_email_label"
= f.label "email", t("labels.email"), :id => "user_email_label"
= f.text_field "email", :tabindex => 1
= f.label "name", "Name", :id => "user_name_label"
= f.label "name", t("labels.name"), :id => "user_name_label"
= f.text_field "name", :tabindex => 2
= f.label "organization", "Organization", :id => "user_organization_label"
= f.label "organization", t("labels.organization"), :id => "user_organization_label"
= f.text_field "organization", :tabindex => 3
= f.label "voice_number", "Phone number", :id => "user_voice_number_label"
= f.label "voice_number", t("labels.voice_number"), :id => "user_voice_number_label"
= f.text_field "voice_number", :tabindex => 4
= f.label "sms_number", "SMS number", :id => "user_sms_number_label"
= f.label "sms_number", t("labels.sms_number"), :id => "user_sms_number_label"
= f.text_field "sms_number", :tabindex => 5
= f.label "password", "New password", :id => "user_password_label"
= f.label "password", t("labels.password_new"), :id => "user_password_label"
%em
(leave blank if you don't want to change it)
= t("captions.password")
= f.password_field "password", :tabindex => 6
= f.label "current_password", "Current password", :id => "user_current_password_label"
= f.label "current_password", t("labels.password_current"), :id => "user_current_password_label"
%em
= t("captions.current_password")
(we need your current password to confirm your changes)
= f.password_field "current_password", :tabindex => 7
= f.submit "Update", :tabindex => 8
= f.submit t("buttons.update"), :tabindex => 8
= render :partial => 'hydrants/back'

View File

@ -1,5 +1,5 @@
%h2
= "#{@hydrant.name ? @hydrant.name.titleize : 'This hydrant'} has been adopted by #{@hydrant.user.name}"
= t("titles.adopted", :hydrant_name => @hydrant.name ? @hydrant.name.titleize : t("defaults.hydrant_name"), :name => @hydrant.user.name)
- unless @hydrant.user.organization.blank?
%h3
= "of #{@hydrant.user.organization}"

View File

@ -1,5 +1,5 @@
%h2
Thank you for adopting this hydrant!
= t("titles.thank_you")
= render :partial => 'hydrants/abandon'
= render :partial => 'users/edit_profile'
= render :partial => 'sessions/sign_out'

View File

@ -0,0 +1,4 @@
require 'rack'
require 'rack/contrib'
Rails.application.config.middleware.use Rack::Locale

View File

@ -1,5 +1,55 @@
# Sample localization file for English. Add more files in this directory for other locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
# Please maintain alphabetical order
en:
hello: "Hello world"
buttons:
abandon: "Abandon this hydrant"
adopt: "Adopt!"
back: "Back"
change_password: "Change my password"
edit_profile: "Edit profile"
email_password: "Email me my password"
find: "Find fire hydrants"
send_reminder: "Send reminder to shovel"
sign_in: "Sign in"
sign_out: "Sign out"
sign_up: "Sign up"
steal: "Steal this hydrant"
update: "Update"
captions:
password: "(leave blank if you don't want to change it)"
password_current: "(we need your current password to confirm your changes)"
defaults:
city: "Boston, MA"
hydrant_name: "This hydrant"
tagline: "Claim responsibility for shoveling out a fire hydrant after it snows."
tos: "By signing up, you agree to the %{tos}."
labels:
address: "Address, Neighborhood"
city_state: "City"
email: "Email address"
name: "Name"
name_hydrant: "Give this hydrant a name"
organization: "Organization"
password: "Password"
password_choose: "Choose a password"
password_current: "Current password"
password_new: "New password"
remember_me: "Stay signed in"
sms_number: "Mobile phone number"
user_existing: "I've already signed up"
user_new: "I haven't signed up yet"
voice_number: "Home phone number"
links:
feedback: "Feedback"
forgot_password: "Forgot your password?"
remembered_password: "Never mind. I remembered my password."
titles:
adopt: "Adopt this Hydrant"
adopted: "%{hydrant_name} has been adopted by %{name}"
edit_profile: "Edit your Profile"
main: "Adopt a Hydrant"
thank_you: "Thank you for adopting this hydrant!"
tos: "Terms of Service"
sponsors:
cfa: "Code for America"
city: "City of Boston"

0
locale.rb Normal file
View File