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

Add a locale switcher, second try #656

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions app/assets/stylesheets/components/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -145,3 +145,7 @@ footer {
color: #BE1E2D;
}
}

.locale_link {
margin: 0px 5px;
}
19 changes: 16 additions & 3 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,22 @@ def mobile_filter_header
end

def switch_locale(&action)
locale = http_accept_language.language_region_compatible_from(I18n.available_locales)
locale ||= I18n.default_locale
I18n.with_locale(current_locale, &action)
end

def default_url_options
{ locale: I18n.locale }
end

def current_locale
LocaleService.call(params[:locale], http_accept_locale)
end

helper_method :current_locale

private

I18n.with_locale(locale, &action)
def http_accept_locale
http_accept_language.language_region_compatible_from(I18n.available_locales)
end
end
17 changes: 17 additions & 0 deletions app/services/locale_service.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class LocaleService
def self.call(param_locale, browser_locale)
new(param_locale, browser_locale).perform
end

def initialize(param_locale, browser_locale)
@param_locale = param_locale
@browser_locale = browser_locale
@default = I18n.default_locale
end

def perform
return @param_locale if @param_locale.present?

@browser_locale || @default
end
end
18 changes: 17 additions & 1 deletion app/views/layouts/_footer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,20 @@
%a{:href => "https://patreon.com/refugerestrooms"} #{t('.on-patreon')}
%br/
= "\© #{t('.copyleft')} #{Date.today.year} #{t('.refuge-restrooms')}".html_safe

%br/
%br/
= link_to 'English', request.query_parameters.merge(locale: 'en'), class: 'locale_link'
•
= link_to 'Español', request.query_parameters.merge(locale: 'es'), class: 'locale_link'
•
= link_to 'Filipino/Tagalog', request.query_parameters.merge(locale: 'fil'), class: 'locale_link'
•
= link_to 'Français', request.query_parameters.merge(locale: 'fr'), class: 'locale_link'
•
= link_to 'हिन्दी', request.query_parameters.merge(locale: 'hi'), class: 'locale_link'
•
= link_to 'Italiano', request.query_parameters.merge(locale: 'it'), class: 'locale_link'
•
= link_to 'polski', request.query_parameters.merge(locale: 'pl'), class: 'locale_link'
•
= link_to 'Português do Brasil', request.query_parameters.merge(locale: 'pt-BR'), class: 'locale_link'
4 changes: 2 additions & 2 deletions app/views/layouts/_navigation.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%nav.nav.navbar-default{:role => "navigation"}
/ Brand and toggle get grouped for better mobile display
.navbar-header
%a#logo.toiletLogo{:href => "/"}
= link_to root_path, id: 'logo', class: 'toiletLogo' do
.navbar-brand Refuge Restrooms
%button.navbar-toggle{"data-target" => "#bs-example-navbar-collapse-1", "data-toggle" => "collapse", :type => "button"}
%span.sr-only= t('.toggle-navigation-button-label')
Expand All @@ -21,5 +21,5 @@
%b.caret
%ul.dropdown-menu
%li= link_to t('.download-unisex-restroom-signs-hyperlink-label'), page_path('signs')
%li= link_to t('.public-api-hyperlink-label'), '/api/docs/'
%li= link_to t('.public-api-hyperlink-label'), api_docs_path
/ /.navbar-collapse
1 change: 1 addition & 0 deletions app/views/layouts/_search.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
= form_tag restrooms_path, class: "search-restrooms-form", method: :get do
= hidden_field_tag :lat, ""
= hidden_field_tag :long, ""
= hidden_field_tag :locale, current_locale
.input-group
= text_field_tag :search, params[:search], class: "form-control search-bar", aria: {label: t("search_bar.enter_location")}
.input-group-btn
Expand Down
4 changes: 2 additions & 2 deletions app/views/pages/about.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
%h3
= t('about.p6header')
%p
= t('about.p6').html_safe

- @business_faq_link = link_to t('about.p6.business_faq'), page_path('business_info')
= t('about.p6.text', business_faq_variable: @business_faq_link).html_safe
3 changes: 2 additions & 1 deletion app/views/pages/business_info.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
%h3
= t('business_info.p1header')
%p
= t('business_info.p1').html_safe
- @about_link_helper = link_to t('business_info.p1.about_page'), page_path('about')
= t('business_info.p1.text', about_page_variable: @about_link_helper).html_safe
%h3
= t('business_info.p2header')
%p
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en/about.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ en:
third: "<strong>Thirdly:</strong> If you know how to code, visit GitHub and let us know about a bug, suggest an improvement, or even contribute a little bit of code and help out the project. REFUGE is open source and we can't do it without you."
fourth: "<strong>Fourthly: </strong> Donate. Keep your eyes peeled for an upcoming crowd funding campaign to fund some of the technology we need to use as well as to pay our fabulous designers and engineers a little bit of money for their hard and tireless work. They have been working for free to bring this service to you and we don't want anybody to work for free. Most of the core team are transgender and underemployed at this time."
p6header: "Why is my business or organization listed?"
p6: "Find out more on our <a href='/business_info'>Business FAQ</a>!"
p6:
text: "Find out more on our %{business_faq_variable}!"
business_faq: "Business FAQ"
contribute: 'Fork us and contribute on GitHub!'
5 changes: 3 additions & 2 deletions config/locales/en/business_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ en:
business_info:
title: "Refuge Restrooms Business Info"
p1header: "1) What is Refuge Restrooms?"
p1: "REFUGE is a web application that seeks to provide safe restroom access for transgender, intersex, and gender nonconforming individuals. Read more about us on our <a href='/about'>About Page</a>."
p1:
text: "REFUGE is a web application that seeks to provide safe restroom access for transgender, intersex, and gender nonconforming individuals. Read more about us on our %{about_page_variable}."
about_page: "About Page"
p2header: "2) How did my facility get on this list?"
p2: "Someone used your restroom and wanted to submit your location as a resource. All our data is crowd-sourced and user-submitted."
p3header: "3) How can I be a good host?"
Expand All @@ -21,4 +23,3 @@ en:
p5: "Reviews help visitors share experiences with each other about the location. We encourage visitors to share as much information as we have about each location on the map."
p6header: "6) How do I remove my listing?"
p6: "We hope you'll consider keeping your listing; it can mean a lot for people's health and wellbeing. However, if you'd rather not be listed, use our contact form to request a removal and our volunteers will work on it as soon as we can (this is an open source project so all work is done by volunteers)."

4 changes: 3 additions & 1 deletion config/locales/es/about.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ es:
third: "<strong>Tercero:</strong> Sí sabe de programación, puedes visitar GitHub para avisarnos sobre un problema técnico (bug), para añadir un issue, o puede constribuir código para ayudarnos con el proyecto. REFUGE es de código abierto y no podemos hacerlo sin usted."
fourth: "<strong>Cuarto: </strong> Donar. Mantente en alerta, proxímamente habra una campaña de financiamiento masiva, para poder acceder a la tecnología que necesitamos usar y para poder pagarle un poco a quienes diseñan y desarrollan nuestra tecnología por su gran esfuerzo incansable. Han estado trabajando gratuitamente para traerte este servicio y no queremos que trabajen gratis. La mayoría de nuesto equipo principal son personas trans y están con bajo empleo en este momento."
p6header: "¿Por qué aparece mi organización o empresa en su listado?"
p6: "Obtenga más información sobre nuestras <a href='/business_info'>preguntas frecuentes para organizaciones y empresas</a>!"
p6:
text: "Obtenga más información sobre nuestras %{business_faq_variable}!"
business_faq: "preguntas frecuentes para organizaciones y empresas"
contribute: 'Haz un Fork para contribuir en GitHub!'
4 changes: 3 additions & 1 deletion config/locales/es/business_info.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ es:
business_info:
title: "Preguntas frecuentes para organizaciones y empresas sobre Refuge Restrooms"
p1header: "1) ¿Qué es Refuge Restrooms?"
p1: "REFUGE es una aplicación web que busca proveer acceso seguro a baños para personas trans, intersexo, y personas género no conformes. Puedes leer más en <a href='/about'>Acerca de REFUGE</a>."
p1:
text: "REFUGE es una aplicación web que busca proveer acceso seguro a baños para personas trans, intersexo, y personas género no conformes. Puedes leer más en %{about_page_variable}."
about_page: "Acerca de REFUGE"
p2header: "2) ¿Cómo llegó mi instalación a esta lista?"
p2: "Alguien usó su baño y quizo enviar su ubicación como recurso. Todos nuestros datos son de fuentes múltiples y enviados por el usuario"
p3header: "3) ¿Cómo puedo ser un buen anfitrión?"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/fil/about.fil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ fil:
third: "<strong>Ikatlo:</strong> Kung alam mo kun paano mag-code, bumisita sa GitHub at ipaalam sa amin ang tungkol sa bug, magmungkahi ng mga pagpapahusay, o kaya mag-ambag ng kunting code at tumulong sa proyektong ito. Ang REFUGE ay isang open source at hindi namin ito magagawa kung wala kayo."
fourth: "<strong>Ikaapat: </strong> Mag-ambag. Maging mapagmatyag sa darating na pangangalap ng pondo mula sa mga tao para makapaglikha ng pondo sa iilang teknolohiya na kinakailangan gamitin pati narin ang pagbayad sa mga taga-desinyo at mga inhinyero kahit sa maliit na halaga para sa kanilang sipag at walang pagud na paggawa. Sila ay nagtratrabaho ng walang bayad para makapaghatid ng serbisyo sa inyo at hindi namin gusto na magtratrabaho ang sinuman ng libre. Karamihan sa aming grupo ay transgender at mga walang trabaho sa ngayon."
p6header: "Bakit nakalista ang aking negosyo o organisasyon?"
p6: "Alamin ang higit pa sa aming <a href='/business_info'>Impormasyon tungkol sa aming ginagawa</a>!"
p6:
text: "Alamin ang higit pa sa aming %{business_faq_variable}!"
business_faq: "Impormasyon tungkol sa aming ginagawa"
contribute: 'I-fork mo kami at mag-ambag sa GitHub!'
4 changes: 3 additions & 1 deletion config/locales/fil/business_info.fil.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ fil:
business_info:
title: "Impormasyon tungkol sa ginagawa ng Refuge Restrooms"
p1header: "1) Ano ang Refuge Restrooms?"
p1: "Ang REFUGE ay isang web application na naglalayong magbigay ng ligtas na akses sa banyo para sa mga transgender, intersex, at mga indibidwal na di-magkatulad na kasarian. Magbasa nang higit pa tungkol sa amin sa aming <a href='/about'>Tungkol sa Pahina</a>."
p1:
text: "Ang REFUGE ay isang web application na naglalayong magbigay ng ligtas na akses sa banyo para sa mga transgender, intersex, at mga indibidwal na di-magkatulad na kasarian. Magbasa nang higit pa tungkol sa amin sa aming %{about_page_variable}."
about_page: "Tungkol sa Pahina"
p2header: "2) Paano napalista ang aking pasilidad sa listahang ito?"
p2: "Mayroong gumamit ang iyong banyo at isinumite ang iyong lokasyon bilang mapagkukunan. Ang lahat ng aming data ay isinumite ng iba't ibang taong mga gumagamit nito."
p3header: "3) Paano ako magiging isang mahusay na host?"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/fr/about.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ fr:
third: "<strong>3.</strong> Si vous savez coder, visitez GitHub et informez-nous d'un bug, suggérez une amélioration, ou ajoutez un peu de code et aidez le projet. REFUGE est open source et nous ne pouvons pas le faire sans vous."
fourth: "<strong>4.</strong> Faites un don. Gardez les yeux ouverts pour une campagne de crowdfunding à venir pour financer une partie de la technologie dont nous avons besoin et pour payer un peu nos fabuleux designers et développeurs pour leur travail acharné et inlassable. Ils ont travaillé gratuitement pour vous offrir ce service et nous pensons que tout travail mérite salaire. La plupart des membres de l'équipe de base sont transgenres et sous-employés en ce moment."
p6header: "Pourquoi mon entreprise ou organisation est-elle répertoriée ?"
p6: "En savoir plus sur notre <a href='/business_info'>Business FAQ</a>!"
p6:
text: "En savoir plus sur notre %{business_faq_variable}!"
business_faq: "Business FAQ"
contribute: 'Contribuez sur GitHub!'
4 changes: 3 additions & 1 deletion config/locales/fr/business_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ fr:
business_info:
title: "Questions fréquentes des organisations et entreprises à propos de Refuge Restrooms"
p1header: "1) Qu'est ce que Refuge Restrooms ?"
p1: "REFUGE est une application web visant à fournir un accès sécurisé à des toilettes aux personnes transgenres, intersexuées et non conformes dans le genre. En lire plus à propos de nous sur notre <a href='/about'>page À Propos</a>."
p1:
text: "REFUGE est une application web visant à fournir un accès sécurisé à des toilettes aux personnes transgenres, intersexuées et non conformes dans le genre. En lire plus à propos de nous sur notre %{about_page_variable}."
about_page: "page À Propos"
p2header: "2) Comment mon établissement est-il entré dans cette liste ?"
p2: "Quelqu'un a utilisé vos toilettes et voulait soumettre votre emplacement en tant que ressource. Toutes nos données sont fournies par l'utilisateur et soumises par l'utilisateur."
p3header: "3) Comment puis-je être un bon hôte ?"
Expand Down
4 changes: 3 additions & 1 deletion config/locales/hi/about.hi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ hi:
third: "<strong> तीसरा: </ strong> यदि आप कोड करना जानते हैं, तो गिटहब (github) पर जाएं और हमें बग के बारे में बताएं, सुधार का सुझाव दें, या यहां तक ​​कि थोड़ा सा कोड भी योगदान दें और परियोजना की सहायता करें। रिफ्यूज खुला स्रोत है और हम आपके बिना यह नहीं कर सकते हैं। "
fourth: "<strong> चौथा: </ strong> दान करें। आने वाली फंडिंग अभियान के लिए अपनी आंखों को खुला रखे। व्यवस्था को चालू रखने के लिए हमे कुछ तकनीकों के प्रयोग के लिए धनराशि की आवशयकता हैं , उसके साथ-साथ हमारे शानदार डिजाइनरों और इंजीनियरों को थोड़ी सी धनराशि का भुगतान करे उनकी कड़ी और अथक म्हणत के लिए । वे इस सेवा को आपके पास लाने के लिए स्वतंत्र रूप से काम कर रहे हैं और हम नहीं चाहते कि कोई भी मुफ्त में काम करे। अधिकांश कोर टीम इस समय ट्रांसजेंडर और बेरोजगार हैं। "
p6header: "मेरा व्यवसाय या संगठन क्यों सूचीबद्ध है?"
p6: "हमारे <a href='/business_info'> व्यवसाय पूछे जाने वाले प्रश्न </a> पर और जानें!"
p6:
text: "हमारे %{business_faq_variable} पर और जानें!"
business_faq: "व्यवसाय पूछे जाने वाले प्रश्न"
contribute: 'हमें फोर्क करें और गिटहब पर योगदान दें!'
5 changes: 3 additions & 2 deletions config/locales/hi/business_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ hi:
business_info:
title: "रेफ्यूज रेस्टरूम व्यापार जानकारी"
p1header: "1) रेफ्यूज रेस्टरूम क्या हैं ?"
p1: "रेफ्यूज रेस्टरूम एक वेब एप्लिकेशन है जो ट्रांसजेंडर, इंटरसेक्स और लिंग गैर-अनुरूप व्यक्तियों के लिए सुरक्षित रेस्टरूम पहुंच प्रदान करना चाहता है। हमारे <a href='/about'> पृष्ठ </a> पर हमारे बारे में और पढ़ें।"
p1:
text: "रेफ्यूज रेस्टरूम एक वेब एप्लिकेशन है जो ट्रांसजेंडर, इंटरसेक्स और लिंग गैर-अनुरूप व्यक्तियों के लिए सुरक्षित रेस्टरूम पहुंच प्रदान करना चाहता है। हमारे %{about_page_variable} पर हमारे बारे में और पढ़ें।"
about_page: "पृष्ठ"
p2header: "2)इस सूची पर मेरी सुविधा कैसे मिली?"
p2: "किसी ने आपके रेस्टरूम का इस्तेमाल किया और संसाधन के रूप में अपना स्थान जमा करना चाहता था। हमारा सभी डेटा उपयोगकर्ता द्वारा सबमिट किया गया है।"
p3header: "3) मैं एक अच्छा मेजबान कैसे हो सकता हूं?"
Expand All @@ -21,4 +23,3 @@ hi:
p5: "समीक्षा आगंतुकों को स्थान के बारे में एक-दूसरे के साथ अनुभव साझा करने में मदद करती है। हम आगंतुकों के मानचित्र पर प्रत्येक स्थान के बारे में अधिक से अधिक जानकारी साझा करने के लिए प्रोत्साहित करते हैं।"
p6header: "6) मैं अपनी लिस्टिंग कैसे हटा सकता हूं?"
p6: "हमें उम्मीद है कि आप अपनी लिस्टिंग रखने पर विचार करेंगे; इसका मतलब लोगों के स्वास्थ्य और कल्याण के लिए बहुत मायने रख सकता है। हालांकि, अगर आप सूचीबद्ध नहीं होंगे, तो हटाने के अनुरोध के लिए हमारे संपर्क फ़ॉर्म का उपयोग करें और हमारे स्वयंसेवक इस पर काम करेंगे जैसे ही हम कर सकते हैं (यह एक ओपन सोर्स प्रोजेक्ट है इसलिए सभी काम स्वयंसेवकों द्वारा किया जाता है)।"

4 changes: 3 additions & 1 deletion config/locales/it/about.it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,7 @@ it:
third: "<strong>Tre:</strong> Se sai programmare, visita GitHub e facci sapere riguardo a bug, suggerimenti e miglioramenti, o contribuisci anche solo un po' al codice e aiuta il progetto. REFUGE è open source e non possiamo farlo senza di te."
fourth: "<strong>Quattro: </strong> Fai una donazione. Tieni gli occhi aperti per la campagna di crowdfunding in arrivo per finanziare parte della tecnologia che necessitiamo di utilizzare così come per dare ai nostri favolosi designer e ingegneri un po' di soldi per il loro duro e instancabile lavoro. Hanno lavorato gratuitamente per portare a voi questo servizio e noi vogliamo che nessuno lavori gratuitamente. La maggior parte del team principale è transgender e sottoccupato al momento."
p6header: "Perchè la mia attività o la mia organizzazione è in lista?"
p6: "Scopri di più sulla nostra <a href='/business_info'>FAQ commerciale</a>!"
p6:
text: "Scopri di più sulla nostra %{business_faq_variable}!"
business_faq: "FAQ commerciale"
contribute: 'Fai un fork e contribuisci su GitHub!'
Loading