mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-07 00:11:47 +01:00
Changed code to support basic i18n.
Added RubyMine configuration and rvm setup to .gitignore.
This commit is contained in:
parent
04faa5d408
commit
fd3f69d927
99 changed files with 1157 additions and 601 deletions
|
|
@ -33,10 +33,12 @@ class ApplicationController < ActionController::Base
|
|||
before_filter :set_session_expiration
|
||||
before_filter :set_time_zone
|
||||
before_filter :set_zindex_counter
|
||||
before_filter :set_locale
|
||||
prepend_before_filter :login_required
|
||||
prepend_before_filter :enable_mobile_content_negotiation
|
||||
after_filter :set_locale
|
||||
after_filter :set_charset
|
||||
|
||||
|
||||
include ActionView::Helpers::TextHelper
|
||||
include ActionView::Helpers::SanitizeHelper
|
||||
extend ActionView::Helpers::SanitizeHelper::ClassMethods
|
||||
|
|
@ -47,6 +49,12 @@ class ApplicationController < ActionController::Base
|
|||
headers["Content-Type"] ||= "text/html; charset=UTF-8"
|
||||
end
|
||||
|
||||
def set_locale
|
||||
locale = params[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first
|
||||
I18n.locale = I18n::available_locales.include?(locale) ? locale : I18n.default_locale
|
||||
logger.debug("Selected '#{I18n.locale}' as locale")
|
||||
end
|
||||
|
||||
def set_session_expiration
|
||||
# http://wiki.rubyonrails.com/rails/show/HowtoChangeSessionOptions
|
||||
unless session == nil
|
||||
|
|
@ -196,7 +204,7 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def admin_login_required
|
||||
unless User.find_by_id_and_is_admin(session['user_id'], true)
|
||||
render :text => "401 Unauthorized: Only admin users are allowed access to this function.", :status => 401
|
||||
render :text => t('errors.user_unauthorized'), :status => 401
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ class LoginController < ApplicationController
|
|||
return
|
||||
else
|
||||
@login = params['user_login']
|
||||
notify :warning, "Login unsuccessful"
|
||||
notify :warning, t('login.unsuccessful')
|
||||
end
|
||||
when :get
|
||||
if User.no_users_yet?
|
||||
|
|
@ -73,7 +73,7 @@ class LoginController < ApplicationController
|
|||
CASClient::Frameworks::Rails::Filter.logout(self)
|
||||
else
|
||||
reset_session
|
||||
notify :notice, "You have been logged out of Tracks."
|
||||
notify :notice, t('login.logged_out')
|
||||
redirect_to_login
|
||||
end
|
||||
end
|
||||
|
|
@ -88,7 +88,7 @@ class LoginController < ApplicationController
|
|||
expiry_time = session['expiry_time'] || Time.now + 10
|
||||
@time_left = expiry_time - Time.now
|
||||
if @time_left < (10*60) # Session will time out before the next check
|
||||
@msg = "Session has timed out. Please "
|
||||
@msg = 'login.session_time_out'
|
||||
else
|
||||
@msg = ""
|
||||
end
|
||||
|
|
@ -107,8 +107,8 @@ class LoginController < ApplicationController
|
|||
if session[:cas_user]
|
||||
if @user = User.find_by_login(session[:cas_user])
|
||||
session['user_id'] = @user.id
|
||||
msg = (should_expire_sessions?) ? "will expire after 1 hour of inactivity." : "will not expire."
|
||||
notify :notice, "Login successful: session #{msg}"
|
||||
msg = (should_expire_sessions?) ? t('login.session_will_expire', :hours => 1) : t('login.session_will_not_expire')
|
||||
notify :notice, (t('login.successful_with_session_info') + msg)
|
||||
cookies[:tracks_login] = { :value => @user.login, :expires => Time.now + 1.year, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
unless should_expire_sessions?
|
||||
@user.remember_me
|
||||
|
|
@ -116,7 +116,7 @@ class LoginController < ApplicationController
|
|||
end
|
||||
#redirect_back_or_home
|
||||
else
|
||||
notify :warning, "Sorry, no user by that CAS username exists (#{session[:cas_user]})"
|
||||
notify :warning, t('login.cas_username_not_found', :username => session[:cas_user])
|
||||
redirect_to signup_url ; return
|
||||
end
|
||||
else
|
||||
|
|
@ -149,8 +149,8 @@ class LoginController < ApplicationController
|
|||
if result.successful?
|
||||
if @user = User.find_by_open_id_url(identity_url)
|
||||
session['user_id'] = @user.id
|
||||
msg = (should_expire_sessions?) ? "will expire after 1 hour of inactivity." : "will not expire."
|
||||
notify :notice, "Login successful: session #{msg}"
|
||||
msg = (should_expire_sessions?) ? t('login.session_will_expire', :hours => 1) : t('login.session_will_not_expire')
|
||||
notify :notice, (t('login.successful_with_session_info') + msg)
|
||||
cookies[:tracks_login] = { :value => @user.login, :expires => Time.now + 1.year, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
unless should_expire_sessions?
|
||||
@user.remember_me
|
||||
|
|
@ -158,7 +158,7 @@ class LoginController < ApplicationController
|
|||
end
|
||||
redirect_back_or_home
|
||||
else
|
||||
notify :warning, "Sorry, no user by that identity URL exists (#{identity_url})"
|
||||
notify :warning, t('login.openid_identity_url_not_found', :identity_url => identity_url)
|
||||
end
|
||||
else
|
||||
notify :warning, result.message
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class RecurringTodosController < ApplicationController
|
|||
@no_completed_recurring_todos = @completed_recurring_todos.size == 0
|
||||
@count = @recurring_todos.size
|
||||
|
||||
@page_title = "TRACKS::Recurring Actions"
|
||||
@page_title = t('todos.recurring_actions_title')
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
|||
10
app/controllers/stats_controller.rb
Executable file → Normal file
10
app/controllers/stats_controller.rb
Executable file → Normal file
|
|
@ -376,7 +376,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
if size==pie_cutoff
|
||||
@actions_per_context[size-1]['name']='(others)'
|
||||
@actions_per_context[size-1]['name']=t('stats.other_actions_label')
|
||||
@actions_per_context[size-1]['total']=0
|
||||
@actions_per_context[size-1]['id']=-1
|
||||
(size-1).upto @all_actions_per_context.size()-1 do |i|
|
||||
|
|
@ -417,7 +417,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
if size==pie_cutoff
|
||||
@actions_per_context[size-1]['name']='(others)'
|
||||
@actions_per_context[size-1]['name']=t('stats.other_actions_label')
|
||||
@actions_per_context[size-1]['total']=0
|
||||
@actions_per_context[size-1]['id']=-1
|
||||
(size-1).upto @all_actions_per_context.size()-1 do |i|
|
||||
|
|
@ -565,7 +565,7 @@ class StatsController < ApplicationController
|
|||
end
|
||||
|
||||
def show_selected_actions_from_chart
|
||||
@page_title = "TRACKS::Action selection"
|
||||
@page_title = t('stats.action_selection_title')
|
||||
@count = 99
|
||||
|
||||
@source_view = 'stats'
|
||||
|
|
@ -582,10 +582,10 @@ class StatsController < ApplicationController
|
|||
week_to = week_from+1
|
||||
|
||||
@chart_name = "actions_visible_running_time_data"
|
||||
@page_title = "Actions selected from week "
|
||||
@page_title = t('stats.actions_selected_from_week')
|
||||
@further = false
|
||||
if params['id'] == 'avrt_end'
|
||||
@page_title += week_from.to_s + " and further"
|
||||
@page_title += week_from.to_s + t('stats.actions_further')
|
||||
@further = true
|
||||
else
|
||||
@page_title += week_from.to_s + " - " + week_to.to_s + ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue