Browse Source

Fixed locale not found contact form

development
Godwin 8 years ago
parent
commit
553e412685
  1. 16
      app/helpers/application_helper.rb
  2. 3
      app/views/application/_contact.html.haml
  3. 2
      app/views/application/locale_not_available.html.haml

16
app/helpers/application_helper.rb

@ -216,13 +216,21 @@ module ApplicationHelper
content_tag(:span, text.html_safe, id: id, class: 'screen-reader-text') content_tag(:span, text.html_safe, id: id, class: 'screen-reader-text')
end end
def url_for_locale(locale) def url_for_locale(locale, url = nil)
unless url.present?
new_params = params.merge({action: (params[:_original_action] || params[:action])}) new_params = params.merge({action: (params[:_original_action] || params[:action])})
new_params.delete(:_original_action) new_params.delete(:_original_action)
return url_for(new_params.merge({lang: locale.to_s})) if Rails.env.development? || Rails.env.test? if Rails.env.development? || Rails.env.test?
return "https://preview-#{locale.to_s}.bikebike.org#{url_for(new_params)}" if Rails.env.preview? url = url_for(new_params.merge({lang: locale.to_s}))
"https://#{locale.to_s}.bikebike.org#{url_for(new_params)}" else
url = url_for(new_params)
end
end
return url if Rails.env.development? || Rails.env.test?
return "https://preview-#{locale.to_s}.bikebike.org#{url}" if Rails.env.preview?
"https://#{locale.to_s}.bikebike.org#{url}"
end end
def registration_steps(conference = @conference) def registration_steps(conference = @conference)

3
app/views/application/_contact.html.haml

@ -1,5 +1,6 @@
- contact_reason ||= nil - contact_reason ||= nil
= form_tag contact_send_path, class: 'contact-form' do - locale ||= nil
= form_tag (locale.present? ? contact_send_url : url_for_locale(locale, contact_send_url)), class: 'contact-form' do
= emailfield :email, nil, big: true, required: true unless logged_in? = emailfield :email, nil, big: true, required: true unless logged_in?
- if contact_reason.present? - if contact_reason.present?
= hidden_field_tag :reason, contact_reason = hidden_field_tag :reason, contact_reason

2
app/views/application/locale_not_available.html.haml

@ -10,4 +10,4 @@
=_'translate.content.change_locale', "Read in #{locale_translation}", vars: {language: locale_translation}, locale: locale =_'translate.content.change_locale', "Read in #{locale_translation}", vars: {language: locale_translation}, locale: locale
%h2= _'error.locale_not_available.volunteer.title' %h2= _'error.locale_not_available.volunteer.title'
%p= _'error.locale_not_available.volunteer.description' %p= _'error.locale_not_available.volunteer.description'
= render 'contact', cancel_btn: false, contact_reason: :website = render 'contact', cancel_btn: false, contact_reason: :website, locale: :en
Loading…
Cancel
Save