Fixed a few bugs, added Arabic to language options, added translations

This commit is contained in:
Godwin
2016-08-02 17:17:52 -07:00
parent e73ed71e32
commit b82c862cad
10 changed files with 43 additions and 31 deletions
+6
View File
@@ -1310,6 +1310,12 @@ ul.warnings li,
}
}
.link-dump {
a {
margin: 0.25em;
}
}
#main article #registration-admin-menu {
margin: 1em 0 0;
padding: 0;
+1 -1
View File
@@ -221,7 +221,7 @@ class ApplicationController < LinguaFrancaApplicationController
current_user,
Time.now.strftime("%d/%m/%Y %H:%M")
]
end# if Rails.env.preview? || Rails.env.production?
end if Rails.env.preview? || Rails.env.production?
end
# raise the error if we are in development so that we can debug it
+3 -3
View File
@@ -600,12 +600,12 @@ class ConferencesController < ApplicationController
end
if params[:location].present? && params[:location].gsub(/[\s\W]/, '').present? && (l = Geocoder.search(params[:location], language: 'en')).present?
corrected = view_context.location(l.first)
corrected = view_context.location(l.first, @this_conference.locale)
if corrected.present?
@registration.city = corrected
if params[:location].gsub(/[\s,]/, '').downcase != @registration.city.gsub(/[\s,]/, '').downcase
@warnings << view_context._('warnings.messages.location_corrected',"Your location was corrected from \"#{params[:location]}\" to \"#{corrected}\". If this doesn't reflect your intended location, you can change this again in the contact info step.", vars: {original: params[:location], corrected: corrected})
@warnings << view_context._('warnings.messages.location_corrected', vars: {original: params[:location], corrected: corrected})
end
else
@errors[:location] = :unknown
@@ -1995,7 +1995,7 @@ class ConferencesController < ApplicationController
steps -= [:questions] unless status == :open
steps -= [:payment] unless status == :open && conference.paypal_email_address.present? && conference.paypal_username.present? && conference.paypal_password.present? && conference.paypal_signature.present?
if @registration.present?
if view_context.same_city?(@registration.city, conference.location)
if view_context.same_city?(@registration.city, view_context.location(conference.location, conference.locale))
steps -= [:questions]
else
steps -= [:hosting]
+4 -9
View File
@@ -525,11 +525,6 @@ module ApplicationHelper
subdomain == 'test'
end
#def location(location)
# territory = Carmen::Country.coded(location.country).subregions.coded(location.territory)
# location.city + (territory ? ' ' + territory.name : '') + ', ' + Carmen::Country.coded(location.country).name
#end
def rand_hash(length = 16, model = nil, field = nil)
if field
hash = rand_hash(length)
@@ -580,7 +575,7 @@ module ApplicationHelper
YAML.load(File.read(Rails.root.join("config/#{name.to_s}.yml")))[Rails.env].symbolize_keys
end
def location(location)
def location(location, locale = I18n.locale)
return nil if location.blank?
city = nil
@@ -613,11 +608,11 @@ module ApplicationHelper
hash = Hash.new
hash[:city] = _!(city) unless city.blank?
hash[:region] = _("geography.subregions.#{country}.#{region}") unless region.blank? || country.blank?
hash[:country] = _("geography.countries.#{country}") unless country.blank?
hash[:region] = _("geography.subregions.#{country}.#{region}", locale: locale) unless region.blank? || country.blank?
hash[:country] = _("geography.countries.#{country}", locale: locale) unless country.blank?
# return the formatted location or the first value if we only have one value
return hash.length > 1 ? _("geography.formats.#{hash.keys.join('_')}", vars: hash) : hash.values.first
return hash.length > 1 ? _("geography.formats.#{hash.keys.join('_')}", locale: locale, vars: hash) : hash.values.first
end
def same_city?(location1, location2)
+4
View File
@@ -40,6 +40,10 @@ class User < ActiveRecord::Base
role == 'administrator'
end
def self.AVAILABLE_LANGUAGES
[:en, :es, :fr, :ar]
end
def self.get(email)
user = where(email: email).first
@@ -9,14 +9,15 @@
= link_to (_'actions.conference.edit_registration'), register_path(@conference.slug), class: :button
- if @conferences.present?
%h3=_'articles.user_settings.headings.Your_Conferences'
- @conferences.each do | conference |
= link_to (_!conference.title), administration_step_path(conference.slug, :edit), class: :button
.link-dump
- @conferences.each do | conference |
= link_to (_!conference.title), administration_step_path(conference.slug, :edit), class: :button
= form_tag update_settings_path do
= textfield :name, current_user.name, required: true, heading: 'articles.conference_registration.headings.name', big: true
= checkboxes :languages, [:en, :es, :fr], current_user.languages || [I18n.locale], 'languages', heading: 'articles.conference_registration.headings.languages'
= radiobuttons :preferred_language, [:en, :es, :fr], current_user.locale || I18n.locale, 'languages', heading: 'articles.conference_registration.headings.preferred_language'
= checkboxes :languages, User.AVAILABLE_LANGUAGES, current_user.languages || [I18n.locale], 'languages', heading: 'articles.conference_registration.headings.languages'
= radiobuttons :preferred_language, I18n.backend.enabled_locales, current_user.locale || I18n.locale, 'languages', heading: 'articles.conference_registration.headings.preferred_language'
= checkbox :email_subscribe, current_user.is_subscribed != false, 'articles.user_settings.email_subscribe', heading: 'articles.user_settings.headings.email_subscribe', help: 'articles.user_settings.paragraphs.email_subscribe', inline: true, right_help: true
.actions
= button_tag :save, value: :save
@@ -3,7 +3,7 @@
= form_tag register_path(@this_conference.slug) do
= textfield :name, @name, required: true, heading: 'articles.conference_registration.headings.name', big: true
= textfield :location, (params[:location] || @registration.city || location(lookup_ip_location)), required: true, heading: 'articles.conference_registration.headings.location'
= checkboxes :languages, [:en, :es, :fr], current_user.languages || [I18n.locale], 'languages', heading: 'articles.conference_registration.headings.languages'
= checkboxes :languages, User.AVAILABLE_LANGUAGES, current_user.languages || [I18n.locale], 'languages', heading: 'articles.conference_registration.headings.languages'
.actions.next-prev
= button_tag (params[:step] == :save ? :save : :next), value: :contact_info
= button_tag :previous, value: :prev_contact_info, class: :subdued, formnovalidate: true
+1 -1
View File
@@ -20,7 +20,7 @@
= textarea :info, @info, help: 'articles.workshops.paragraphs.info', lang: @translation, original_value: @is_translating ? richtext(@workshop.info!, 4).html_safe : nil, original_lang: @workshop.locale
- if !@is_translating && (@workshop.id.blank? || @can_edit)
= columns(medium: 6) do
= checkboxes :languages, [:en, :es, :fr], @languages, 'languages', vertical: true, heading: 'articles.workshops.headings.languages', help: 'articles.workshops.paragraphs.languages'
= checkboxes :languages, User.AVAILABLE_LANGUAGES, @languages, 'languages', vertical: true, heading: 'articles.workshops.headings.languages', help: 'articles.workshops.paragraphs.languages'
= radiobuttons :theme, Workshop.all_themes, @workshop.theme, 'workshop.options.theme', vertical: true, heading: 'articles.workshops.headings.theme', help: 'articles.workshops.paragraphs.theme', other: true
= columns(medium: 6) do
= checkboxes :needs, Workshop.all_needs, JSON.parse(@workshop.needs || '[]'), 'workshop.options.needs', vertical: true, heading: 'articles.workshops.headings.needs', help: 'articles.workshops.paragraphs.needs'