Skip to content

Commit

Permalink
Contact page: Make translation-ready
Browse files Browse the repository at this point in the history
* Updates `app/views/contacts/new.html.haml`
  to evaluate translation strings

* Add translation strings in `config/locales/contacts.en.yml`

* Also updates `config/locales/simple_form.en.yml`
  to translate input forms on Contact page

* Difficult to make "Thank you for contacting us" page
  translation-ready, so ignored that for now.
  • Loading branch information
DeeDeeG committed Jan 15, 2018
1 parent ce2cb91 commit dd0a1f1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/views/contacts/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- if @contact.restroom_name.present?
%h1 Request Edit for #{@contact.restroom_name} Restroom
%h1= t('.request-edit')
- else
%h1 Contact
%h1= t('.contact-title')
= simple_form_for @contact, html: {class: 'form-vertical headroom'} do |f|
%p
= f.input :name, :required => true
Expand All @@ -10,6 +10,6 @@
.hidden
= f.hidden_field :restroom_id, :required => false
= f.hidden_field :restroom_name, :required => false
= f.hidden_field :nickname, :hint => 'Leave this field blank!'
= f.hidden_field :nickname, :hint => t('.leave-this-field-blank')
.form-actions
= f.button :submit, 'Send message', :class=> "linkbutton"
= f.button :submit, :class=> "linkbutton"
6 changes: 6 additions & 0 deletions config/locales/contacts.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
contacts:
new:
request-edit: 'Request Edit for #{@contact.restroom_name} Restroom'
contact-title: 'Contact'
leave-this-field-blank: 'Leave this field blank!'
16 changes: 16 additions & 0 deletions config/locales/simple_form.en.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# See this documentation: https://github.com/plataformatec/simple_form#i18n
# And this StackOverflow answer: https://stackoverflow.com/questions/35906089/changing-simple-form-submit-button-i18n-text

en:
simple_form:
"yes": 'Yes'
Expand All @@ -10,6 +13,19 @@ en:
# html: '<abbr title="required">*</abbr>'
error_notification:
default_message: "Please review the problems below:"

labels:
defaults:
name: 'Name'
email: 'Email'
message: 'Message'

helpers:
submit:
contact:
# This is the "Submit message" button on the "Contact" page.
create: 'Submit message'

# Labels and hints examples
# labels:
# defaults:
Expand Down

0 comments on commit dd0a1f1

Please sign in to comment.