Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make remaining pages translation-ready #421

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions app/views/contacts/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
- if @contact.restroom_name.present?
%h1 Request Edit for #{@contact.restroom_name} Restroom
- titlestring = t('.request-edit-for')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can actually interpolate this. t('request-edit-for', restroom_name: @contact.restroom_name) and then define the translation like this:
request-edit-for: 'Request Edit for %{restroom_name} Restroom'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I18n, takes the param restroom_name and shoves it into the %{restroom_name} param

- titlestring << " "
- titlestring << @contact.restroom_name
- titlestring << " "
- titlestring << t('.restroom')
%h1= titlestring
- 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 +15,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"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see a translation here?

Copy link
Contributor Author

@DeeDeeG DeeDeeG Jan 17, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a weird experience trying to translate this (buttons in simple_form are apparently from some other dimension compared to all other parts of forms) and try as I might, I couldn't figure out a way to translate this with the usual t('key.name.here') format, inline in app/views/contacts/new.html.haml.

per plataformatec/simple_form#i18n:

It's also possible to translate buttons, using Rails' built-in I18n support:

en:
  helpers:
    submit:
      user:
        create: "Add %{model}"
        update: "Save Changes"

The translation ended up here: simple_form.en.yml, Line 27

This seemed like the logical place to put it.

I do notice that I accidentally changed the string from "Send message" -> "Submit message" so I can change that back if you like.

[Edit: Addressed in this commit:] 8f8d7ef

= f.button :submit, :class=> "linkbutton"
20 changes: 10 additions & 10 deletions app/views/layouts/_footer.html.haml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
%footer
.footer
%a.iconLink{:href => "https://github.com/RefugeRestrooms/refugerestrooms", :aria => { :label => "Refuge Restrooms on github"}}
%a.iconLink{:href => "https://github.com/RefugeRestrooms/refugerestrooms", :aria => { :label => t('.refuge-restrooms-on-github-aria-label')}}
%i.icon.fa.fa-github-square.fa-3x
%a.iconLink{:href => "https://twitter.com/refugerestrooms", :aria => { :label => "Refuge Restrooms on twitter"}}
%a.iconLink{:href => "https://twitter.com/refugerestrooms", :aria => { :label => t('.refuge-restrooms-on-twitter-aria-label')}}
%i.icon.fa.fa-twitter-square.fa-3x
%a.iconLink{:href => "https://www.facebook.com/refugerestrooms", :aria => { :label => "Refuge Restrooms on facebook"}}
%a.iconLink{:href => "https://www.facebook.com/refugerestrooms", :aria => { :label => t('.refuge-restrooms-on-facebook-aria-label')}}
%i.icon.fa.fa-facebook-square.fa-3x
%a.iconLink{:href => "http://blog.refugerestrooms.org/", :aria => { :label => "Refuge Restrooms's blog on tumblr"}}
%a.iconLink{:href => "http://blog.refugerestrooms.org/", :aria => { :label => t('.refuge-restrooms-blog-on-tumblr-aria-label')}}
%i.icon.fa.fa-tumblr-square.fa-3x
%a.iconLink{:href => contact_path, :aria => { :label => "Email Refuge Restrooms"}}
%a.iconLink{:href => contact_path, :aria => { :label => t('.email-refuge-restrooms-aria-label')}}
%i.icon.fa.fa-envelope.fa-3x
%br/
refuge restrooms is open source.
%a{:href => "https://github.com/RefugeRestrooms/refugerestrooms"} code on github.
= t('.refuge-restrooms-is-open-source')
%a{:href => "https://github.com/RefugeRestrooms/refugerestrooms"} #{t('.code-on-github')}
%br/
contribute to the project
%a{:href => "https://patreon.com/refugerestrooms"} on patreon.
= t('.contribute-to-the-project')
%a{:href => "https://patreon.com/refugerestrooms"} #{t('.on-patreon')}
%br/
= "\&copy; copyleft #{Date.today.year} refuge restrooms.".html_safe
= "\&copy; #{t('.copyleft')} #{Date.today.year} #{t('.refuge-restrooms')}".html_safe
14 changes: 7 additions & 7 deletions app/views/layouts/_navigation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
%a#logo.toiletLogo{:href => "/"}
.navbar-brand Refuge Restrooms
%button.navbar-toggle{"data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation
%span.sr-only= t('.toggle-navigation-button-label')
%i.fa.fa-bars.fa-2x
/ Collect the nav links, forms, and other content for toggling
#bs-example-navbar-collapse-1.collapse.navbar-collapse
%ul.nav.navbar-nav.navbar-right
%li= link_to "Submit a New Restroom", new_restroom_path
%li= link_to 'About', page_path('about')
%li= link_to 'Contact', contact_path
%li= link_to t('.submit-a-new-restroom-hyperlink-label'), new_restroom_path
%li= link_to t('.about-hyperlink-label'), page_path('about')
%li= link_to t('.contact-hyperlink-label'), contact_path
%li.dropdown
%a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"}
Resources
= t('.resources-dropdown-button-label')
%b.caret
%ul.dropdown-menu
%li
%li= link_to 'Download Unisex Restroom Signs', page_path('signs')
%li= link_to 'Public API', '/api/docs/'
%li= link_to t('.download-unisex-restroom-signs-hyperlink-label'), page_path('signs')
%li= link_to t('.public-api-hyperlink-label'), '/api/docs/'
/ /.navbar-collapse
4 changes: 2 additions & 2 deletions app/views/layouts/_search.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
.input-group
= text_field_tag :search, params[:search], class: "form-control search-bar", aria: {label: t("search_bar.enter_location")}
.input-group-btn
%button.btn.btn-light-purple.submit-search-button{type: "button", title: "Search", value: "Search", aria: { label: "Search" }}
%button.btn.btn-light-purple.submit-search-button{type: "button", title: t('.search'), value: t('.search'), aria: { label: t('.search') }}
%i.fa.fa-search.fa-2x
%i.fa.fa-refresh.fa-spin.fa-2x
%button.btn.btn-light-purple.current-location-button{type: "button", title: "Search by Current Location", aria: { label: "Search by Current Location" }, value: (splash ? "Search Current Location" : nil ) }
%button.btn.btn-light-purple.current-location-button{type: "button", title: t('.search-by-current-location'), aria: { label: t('.search-by-current-location') }, value: (splash ? t('.search-by-current-location') : nil ) }
%i.fa.fa-location-arrow.fa-2x
%i.fa.fa-refresh.fa-spin.fa-2x
6 changes: 3 additions & 3 deletions app/views/pages/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
.col-xs-12.col-sm-8.col-sm-offset-2
.splash-text-container.centered-text
%h3.headroom
Sometimes life is tough...
= t('.life-is-tough')
%h1.centered-text
Find Refuge
= t('.find-refuge')

.row.more-headroom
.col-xs-12.col-sm-8.col-sm-offset-2
Expand All @@ -14,7 +14,7 @@
.row.more-headroom
.col-xs-12.col-sm-6.col-sm-offset-3
= button_to new_restroom_path, method: :get, class: "btn btn-lg btn-purple splash-add-restroom-btn" do
Add A Restroom
= t('.add-restroom-button-label')
%i.fa.fa-plus-square-o.fa-2x
.row.even-more-headroom
.col-xs-6.col-sm-3.col-sm-offset-3
Expand Down
2 changes: 1 addition & 1 deletion app/views/restrooms/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
%i.fa.fa-child

.map-toggle-btn.mapToggle.linkbutton.btn-lg.btn-light-purple
Map View
= t('.map-view-button-label')

.restrooms-index-content
.row
Expand Down
4 changes: 2 additions & 2 deletions app/views/restrooms/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
method: 'put' do
%button.btn.btn-lg.btn-success
%i.fa.fa-thumbs-up
Thumbs Up
= t('.thumbs-up-button-label')

= link_to restroom_path(restroom: { downvote: true }),
method: 'put' do
%button.btn.btn-lg.btn-danger
%i.fa.fa-thumbs-down
Thumbs Down
= t('.thumbs-down-button-label')
.row.headroom
.col-xs-12

Expand Down
7 changes: 7 additions & 0 deletions config/locales/contacts.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
en:
contacts:
new:
request-edit-for: 'Request Edit for'
restroom: 'Restroom'
contact-title: 'Contact'
leave-this-field-blank: 'Leave this field blank!'
14 changes: 14 additions & 0 deletions config/locales/footer.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
en:
layouts:
footer:
refuge-restrooms-on-github-aria-label: 'Refuge Restrooms on GitHub'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd recommend maybe storing these a little differently to make them a little more readable.

footer:
  aria-labels:
    github: 'Refuge Restrooms on Github'
    twitter: 'String Here'

That way when you call them you do t('footer.aira-labels.github')

refuge-restrooms-on-twitter-aria-label: 'Refuge Restrooms on twitter'
refuge-restrooms-on-facebook-aria-label: 'Refuge Restrooms on Facebook'
refuge-restrooms-blog-on-tumblr-aria-label: 'Refuge Restrooms blog on tumblr'
email-refuge-restrooms-aria-label: 'Email Refuge Restrooms'
refuge-restrooms-is-open-source: 'refuge restrooms is open source.'
code-on-github: 'code on github.'
contribute-to-the-project: 'contribute to the project'
on-patreon: 'on patreon.'
copyleft: 'copyleft'
refuge-restrooms: 'refuge restrooms.'
3 changes: 0 additions & 3 deletions config/locales/landing.en.yml

This file was deleted.

11 changes: 11 additions & 0 deletions config/locales/navigation.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
en:
layouts:
navigation:
toggle-navigation-button-label: 'Toggle navigation'
submit-a-new-restroom-hyperlink-label: 'Submit a New Restroom'
about-hyperlink-label: 'About'
contact-hyperlink-label: 'Contact'

resources-dropdown-button-label: 'Resources'
download-unisex-restroom-signs-hyperlink-label: 'Download Unisex Restroom Signs'
public-api-hyperlink-label: Public API
8 changes: 8 additions & 0 deletions config/locales/restrooms.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
en:
restrooms:
index:
map-view-button-label: 'Map View'

show:
thumbs-up-button-label: 'Thumbs Up'
thumbs-down-button-label: 'Thumbs Down'
6 changes: 6 additions & 0 deletions config/locales/search.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
layouts:
search:
search: 'Search'
search-by-current-location: 'Search by Current Location'

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
6 changes: 6 additions & 0 deletions config/locales/splash.en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
en:
pages:
index:
life-is-tough: 'Sometimes life is tough...'
find-refuge: 'Find Refuge'
add-restroom-button-label: 'Add A Restroom'