From dd0a1f1d48c3b0ee0175f4d68eb2aa99f514c696 Mon Sep 17 00:00:00 2001 From: DeeDeeG Date: Sat, 13 Jan 2018 16:44:07 -0500 Subject: [PATCH] Contact page: Make translation-ready * 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. --- app/views/contacts/new.html.haml | 8 ++++---- config/locales/contacts.en.yml | 6 ++++++ config/locales/simple_form.en.yml | 16 ++++++++++++++++ 3 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 config/locales/contacts.en.yml diff --git a/app/views/contacts/new.html.haml b/app/views/contacts/new.html.haml index 263b9052..229dd52d 100644 --- a/app/views/contacts/new.html.haml +++ b/app/views/contacts/new.html.haml @@ -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 @@ -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" diff --git a/config/locales/contacts.en.yml b/config/locales/contacts.en.yml new file mode 100644 index 00000000..1488d3ab --- /dev/null +++ b/config/locales/contacts.en.yml @@ -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!' diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml index 0df11fe0..3eea3513 100644 --- a/config/locales/simple_form.en.yml +++ b/config/locales/simple_form.en.yml @@ -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' @@ -10,6 +13,19 @@ en: # html: '*' 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: