Skip to content

Commit

Permalink
Merge 7943ca6 into 36045c5
Browse files Browse the repository at this point in the history
  • Loading branch information
feliciaan committed Jan 29, 2017
2 parents 36045c5 + 7943ca6 commit 7bbf320
Show file tree
Hide file tree
Showing 19 changed files with 381 additions and 166 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Expand Up @@ -6,6 +6,9 @@ gem 'rails', '~> 4.0'
# I18N
gem 'rails-i18n', '~> 4.0'

# I18n tasks, simplify the process, find missing keys
gem 'i18n-tasks', '~> 0.9.9'

# We <3 New Relic
gem 'newrelic_rpm'

Expand Down
23 changes: 23 additions & 0 deletions Gemfile.lock
Expand Up @@ -55,6 +55,7 @@ GEM
activerecord (>= 3.2, < 6.0)
rake (>= 10.4, < 12.0)
arel (6.0.4)
ast (2.3.0)
bcrypt (3.1.11)
builder (3.2.2)
byebug (9.0.6)
Expand Down Expand Up @@ -128,6 +129,10 @@ GEM
devise (>= 1.2.0)
rubycas-client (>= 2.2.1)
docile (1.1.5)
easy_translate (0.5.0)
json
thread
thread_safe
erubis (2.7.0)
execjs (2.7.0)
faraday (0.10.1)
Expand All @@ -136,10 +141,21 @@ GEM
activesupport (>= 4.1.0)
hashdiff (0.3.2)
hashie (3.4.6)
highline (1.7.8)
hike (1.2.3)
httparty (0.14.0)
multi_xml (>= 0.5.2)
i18n (0.7.0)
i18n-tasks (0.9.9)
activesupport (>= 4.0.2)
ast (>= 2.1.0)
easy_translate (>= 0.5.0)
erubis
highline (>= 1.7.3)
i18n
parser (>= 2.2.3.0)
term-ansicolor (>= 1.3.2)
terminal-table (>= 1.5.1)
iban-tools (1.1.0)
jbuilder (1.5.3)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -197,6 +213,8 @@ GEM
cocaine (~> 0.5.5)
mime-types
mimemagic (= 0.3.0)
parser (2.3.3.1)
ast (~> 2.2)
pdf-core (0.6.1)
poltergeist (1.12.0)
capybara (~> 2.1)
Expand Down Expand Up @@ -305,10 +323,13 @@ GEM
net-ssh (>= 2.8.0)
term-ansicolor (1.4.0)
tins (~> 1.0)
terminal-table (1.7.3)
unicode-display_width (~> 1.1.1)
therubyracer (0.12.3)
libv8 (~> 3.16.14.15)
ref
thor (0.19.4)
thread (0.2.2)
thread_safe (0.3.5)
tilt (1.4.1)
timeliness (0.3.8)
Expand All @@ -325,6 +346,7 @@ GEM
thread_safe (~> 0.1)
uglifier (3.0.4)
execjs (>= 0.3.0, < 3)
unicode-display_width (1.1.3)
warden (1.2.6)
rack (>= 1.0)
webmock (2.3.2)
Expand Down Expand Up @@ -366,6 +388,7 @@ DEPENDENCIES
devise
devise_cas_authenticatable
httparty
i18n-tasks (~> 0.9.9)
iban-tools
jbuilder (~> 1.2)
jc-validates_timeliness
Expand Down
9 changes: 9 additions & 0 deletions app/controllers/application_controller.rb
Expand Up @@ -5,6 +5,15 @@ class ApplicationController < ActionController::Base

after_filter :store_location

before_action :set_locale

def set_locale
I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
if params[:locale]
session[:locale] = params[:locale]
end
end

def store_location
# store last url as long as it isn't a /users path
session[:previous_url] = request.fullpath unless request.fullpath =~ /\/users/
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/application_helper.rb
Expand Up @@ -30,8 +30,8 @@ def form_url_field(f, tag)
render partial: "form_url_field", locals: {f: f, tag: tag}
end

def form_text_area(f, tag)
render partial: "form_text_area", locals: {f: f, tag: tag}
def form_text_area(f, tag, label_text=nil)
render partial: "form_text_area", locals: {f: f, tag: tag, label_text: label_text}
end

def form_fancy_text_area(f, tag)
Expand All @@ -42,8 +42,8 @@ def form_email_field(f, tag)
render partial: "form_email_field", locals: {f: f, tag: tag}
end

def form_telephone_field(f, tag)
render partial: "form_telephone_field", locals: {f: f, tag: tag}
def form_telephone_field(f, tag, show_disclaimer)
render partial: "form_telephone_field", locals: {f: f, tag: tag, show_disclaimer: show_disclaimer}
end

def form_date_field(f, tag, id, value)
Expand Down
53 changes: 28 additions & 25 deletions app/models/event.rb
Expand Up @@ -2,31 +2,34 @@
#
# Table name: events
#
# id :integer not null, primary key
# name :string
# start_date :datetime
# end_date :datetime
# location :string
# website :string
# description :text
# created_at :datetime
# updated_at :datetime
# registration_open_date :datetime
# registration_close_date :datetime
# bank_number :string
# show_ticket_count :boolean default(TRUE)
# contact_email :string
# export_file_name :string
# export_content_type :string
# export_file_size :integer
# export_updated_at :datetime
# show_statistics :boolean
# export_status :string
# club_id :integer
# registration_open :boolean default(TRUE)
# signature :text
# registration_cancelable :boolean
# phone_number_state :string default("optional")
# id :integer not null, primary key
# name :string
# start_date :datetime
# end_date :datetime
# location :string
# website :string
# description :text
# created_at :datetime
# updated_at :datetime
# registration_open_date :datetime
# registration_close_date :datetime
# bank_number :string
# show_ticket_count :boolean default(TRUE)
# contact_email :string
# export_file_name :string
# export_content_type :string
# export_file_size :integer
# export_updated_at :datetime
# show_statistics :boolean
# export_status :string
# club_id :integer
# registration_open :boolean default(TRUE)
# signature :text
# registration_cancelable :boolean
# phone_number_state :string default("optional")
# extra_info :boolean default(FALSE)
# comment_title :string
# show_telephone_disclaimer :boolean default(FALSE)
#

class Event < ActiveRecord::Base
Expand Down
2 changes: 2 additions & 0 deletions app/models/registration.rb
Expand Up @@ -17,6 +17,8 @@
# barcode_data :string
# payment_code :string
# phone_number :string
# title :string
# job_function :string
#

class Registration < ActiveRecord::Base
Expand Down
5 changes: 4 additions & 1 deletion app/views/application/_form_telephone_field.html.erb
@@ -1,5 +1,8 @@
<div class="form-group">
<%= f.label tag %>:<br/>
<%= f.telephone_field tag, class: 'form-control' %>
<small><%= t('forms.field.telephone.privacy_declaration') %></small>
<% if show_disclaimer %>
<small><%= t('forms.field.telephone.privacy_declaration') %></small>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/application/_form_text_area.html.erb
@@ -1,4 +1,4 @@
<div class="form-group">
<%= f.label tag %>:
<%= f.label tag, label_text %>:
<%= f.text_area tag, class: 'form-control' %>
</div>
6 changes: 6 additions & 0 deletions app/views/layouts/_login.html.erb
@@ -1,4 +1,10 @@
<ul class="nav-tertiary nav navbar-nav navbar-right">
<% if I18n.locale == :en %>
<li><a href="<%= url_for params.merge({:locale => 'nl'}) %>"><%= t('dutch') %></a></li>
<% end %>
<% if I18n.locale == :nl %>
<li><a href="<%= url_for params.merge({:locale => 'en'}) %>"><%= t('english') %></a></li>
<% end %>
<% if user_signed_in? %>
<li><a><span>Logged in as <%= current_user.display_name %></span></a></li>
<li><%= link_to destroy_user_session_path(current_user), method: :delete do %><span>Logout</span><% end %></li>
Expand Down
6 changes: 3 additions & 3 deletions app/views/registrations/_basic.html.erb
Expand Up @@ -8,14 +8,14 @@
<%= form_email_field f, :email %>
<%= f.hidden_field :student_number %>
<% if @registration.event.ask_phone_number? %>
<%= form_telephone_field f, :phone_number %>
<%= form_telephone_field f, :phone_number, @event.show_telephone_disclaimer %>
<% end %>
<%= form_collection_select f, :access_levels, @event.access_levels.find_all { |al| can? :register, al }, :id, :name_with_price %>
<%= form_text_area f, :comment %>
<%= form_text_area f, :comment, @event.comment_title %>
<%= javascript_tag do %>
window.ticketsWithComments = <%= @event.access_levels.find_all(&:has_comment).map(&:id).to_json %>
<% end %>
<%= f.submit t('event.register'), class: 'btn btn-group btn-primary' %>
<%= f.submit t('event.register', default: 'Register'), class: 'btn btn-group btn-primary' %>
<% end %>
</p>

Expand Down
121 changes: 121 additions & 0 deletions config/i18n-tasks.yml
@@ -0,0 +1,121 @@
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks

# The "main" locale.
base_locale: nl
## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
locales: [nl, en]
## Reporting locale, default: en. Available: en, ru.
# internal_locale: en

# Read and write translations.
data:
## Translations are read from the file system. Supported format: YAML, JSON.
## Provide a custom adapter:
# adapter: I18n::Tasks::Data::FileSystem

# Locale files or `File.find` patterns where translations are read from:
read:
## Default:
- config/locales/%{locale}.yml
## More files:
# - config/locales/**/*.%{locale}.yml
## Another gem (replace %#= with %=):
# - "<%#= %x[bundle show vagrant].chomp %>/templates/locales/%{locale}.yml"

# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
# `i18n-tasks normalize -p` will force move the keys according to these rules
write:
## For example, write devise and simple form keys to their respective files:
# - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
## Catch-all default:
# - config/locales/%{locale}.yml

## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, or a custom class.
# router: convervative_router

yaml:
write:
# do not wrap lines at 80 characters
line_width: -1

## Pretty-print JSON:
# json:
# write:
# indent: ' '
# space: ' '
# object_nl: "\n"
# array_nl: "\n"

# Find translate calls
search:
## Paths or `File.find` patterns to search in:
# paths:
# - app/

## Root directories for relative keys resolution.
# relative_roots:
# - app/controllers
# - app/helpers
# - app/mailers
# - app/presenters
# - app/views

## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
## %w(*.jpg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less *.yml *.json)
exclude:
- app/assets/images
- app/assets/fonts
- app/assets/videos

## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
# only: ["*.rb", "*.html.slim"]

## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
# strict: true

## Multiple scanners can be used. Their results are merged.
## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example

## Google Translate
# translation:
# # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
# api_key: "AbC-dEf5"

## Do not consider these keys missing:
# ignore_missing:
# - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
# - '{devise,simple_form}.*'

## Consider these keys used:
# ignore_unused:
# - 'activerecord.attributes.*'
# - '{devise,kaminari,will_paginate}.*'
# - 'simple_form.{yes,no}'
# - 'simple_form.{placeholders,hints,labels}.*'
# - 'simple_form.{error_notification,required}.:'

## Exclude these keys from the `i18n-tasks eq-base' report:
# ignore_eq_base:
# all:
# - common.ok
# fr,es:
# - common.brand

## Ignore these keys completely:
# ignore:
# - kaminari.*

## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
## e.g. in case of a relative key defined in a helper method.
## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
#
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
# only: %w(*.html.haml *.html.slim),
# patterns: [['= title\b', '.page_title']] %>
#
# The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
#
# <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
# patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>

0 comments on commit 7bbf320

Please sign in to comment.