mirror of
https://github.com/TracksApp/tracks.git
synced 2026-03-04 03:50:17 +01:00
Added locale selection to preferences
Mostly completed transition to full i18n Incorporated german translations by Ulf Klose <ulf.klose@gmail.com>
This commit is contained in:
parent
d57bd479f9
commit
338d4bb5a6
44 changed files with 1071 additions and 209 deletions
|
|
@ -36,7 +36,7 @@ class ApplicationController < ActionController::Base
|
|||
before_filter :set_locale
|
||||
prepend_before_filter :login_required
|
||||
prepend_before_filter :enable_mobile_content_negotiation
|
||||
after_filter :set_locale
|
||||
# after_filter :set_locale
|
||||
after_filter :set_charset
|
||||
|
||||
include ActionView::Helpers::TextHelper
|
||||
|
|
@ -50,9 +50,10 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def set_locale
|
||||
locale = params[:locale]
|
||||
locale = params[:locale] # specifying a locale in the request takes precedence
|
||||
locale = locale || prefs.locale unless current_user.nil? # otherwise, the locale of the currently logged in user takes over
|
||||
locale = locale || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']
|
||||
I18n.locale = I18n::available_locales.include?(locale) ? locale : I18n.default_locale
|
||||
I18n.locale = I18n::available_locales.include?(locale.to_sym) ? locale : I18n.default_locale
|
||||
logger.debug("Selected '#{I18n.locale}' as locale")
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
class PreferencesController < ApplicationController
|
||||
|
||||
def index
|
||||
@page_title = "TRACKS::Preferences"
|
||||
@page_title = t('preferences.page_title')
|
||||
@prefs = prefs
|
||||
end
|
||||
|
||||
def edit
|
||||
@page_title = "TRACKS::Edit Preferences"
|
||||
@page_title = t('preferences.page_title_edit')
|
||||
end
|
||||
|
||||
def update
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class ProjectsController < ApplicationController
|
|||
def show
|
||||
@max_completed = current_user.prefs.show_number_completed
|
||||
init_data_for_sidebar unless mobile?
|
||||
@page_title = "TRACKS::Project: #{@project.name}"
|
||||
@page_title = t('projects.page_title', :project => @project.name)
|
||||
|
||||
@not_done = @project.not_done_todos_including_hidden
|
||||
@deferred = @project.deferred_todos
|
||||
|
|
@ -204,7 +204,7 @@ class ProjectsController < ApplicationController
|
|||
|
||||
def render_projects_html
|
||||
lambda do
|
||||
@page_title = "TRACKS::List Projects"
|
||||
@page_title = t('projects.list_projects')
|
||||
@count = current_user.projects.size
|
||||
@active_projects = current_user.projects.active
|
||||
@hidden_projects = current_user.projects.hidden
|
||||
|
|
@ -230,10 +230,9 @@ class ProjectsController < ApplicationController
|
|||
def render_project_mobile
|
||||
lambda do
|
||||
if @project.default_context.nil?
|
||||
@project_default_context = "This project does not have a default context"
|
||||
@project_default_context = t('projects.no_default_context')
|
||||
else
|
||||
@project_default_context = "The default context for this project is "+
|
||||
@project.default_context.name
|
||||
@project_default_context = t('projects.default_context', :context => @project.default_context.name)
|
||||
end
|
||||
cookies[:mobile_url]= {:value => request.request_uri, :secure => SITE_CONFIG['secure_cookies']}
|
||||
@mobile_from_project = @project.id
|
||||
|
|
@ -293,7 +292,7 @@ class ProjectsController < ApplicationController
|
|||
project_description = ''
|
||||
project_description += sanitize(markdown( project.description )) unless project.description.blank?
|
||||
project_description += "<p>#{count_undone_todos_phrase(p)}. "
|
||||
project_description += "Project is #{project.state}."
|
||||
project_description += t('projects.project_state', :state => project.state)
|
||||
project_description += "</p>"
|
||||
project_description
|
||||
end
|
||||
|
|
|
|||
|
|
@ -173,7 +173,7 @@ class TodosController < ApplicationController
|
|||
if @todos.size > 0
|
||||
@default_tags = @todos[0].project.default_tags unless @todos[0].project.nil?
|
||||
else
|
||||
@multiple_error = "You need to submit at least one next action"
|
||||
@multiple_error = t('todos.next_action_needed')
|
||||
@saved = false;
|
||||
@default_tags = current_user.projects.find_by_name(@initial_project_name).default_tags unless @initial_project_name.blank?
|
||||
end
|
||||
|
|
@ -277,10 +277,10 @@ class TodosController < ApplicationController
|
|||
format.html do
|
||||
if @saved
|
||||
# TODO: I think this will work, but can't figure out how to test it
|
||||
notify :notice, "The action <strong>'#{@todo.description}'</strong> was marked as <strong>#{@todo.completed? ? 'complete' : 'incomplete' }</strong>"
|
||||
notify(:notice, t("todos.action_marked_complete", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete'))
|
||||
redirect_to :action => "index"
|
||||
else
|
||||
notify :notice, "The action <strong>'#{@todo.description}'</strong> was NOT marked as <strong>#{@todo.completed? ? 'complete' : 'incomplete' } due to an error on the server.</strong>", "index"
|
||||
notify(:notice, t("todos.action_marked_complete_error", :description => @todo.description, :completed => @todo.completed? ? 'complete' : 'incomplete'), "index")
|
||||
redirect_to :action => "index"
|
||||
end
|
||||
end
|
||||
|
|
@ -304,7 +304,7 @@ class TodosController < ApplicationController
|
|||
@saved = @todo.save
|
||||
|
||||
@context_changed = true
|
||||
@message = "Context changed to #{@context.name}"
|
||||
@message = t('todos.context_changed', :name => @context.name)
|
||||
determine_remaining_in_context_count(@original_item_context_id)
|
||||
|
||||
respond_to do |format|
|
||||
|
|
@ -476,14 +476,14 @@ class TodosController < ApplicationController
|
|||
|
||||
format.html do
|
||||
if @saved
|
||||
message = "Successfully deleted next action"
|
||||
message = t('todos.action_deleted_success')
|
||||
if activated_successor_count > 0
|
||||
message += " activated #{pluralize(activated_successor_count, 'pending action')}"
|
||||
end
|
||||
notify :notice, message, 2.0
|
||||
redirect_to :action => 'index'
|
||||
else
|
||||
notify :error, "Failed to delete the action", 2.0
|
||||
notify :error, t('todos.action_deleted_error'), 2.0
|
||||
redirect_to :action => 'index'
|
||||
end
|
||||
end
|
||||
|
|
@ -507,7 +507,7 @@ class TodosController < ApplicationController
|
|||
end
|
||||
|
||||
def completed
|
||||
@page_title = "TRACKS::Completed tasks"
|
||||
@page_title = t('todos.completed_tasks_title')
|
||||
@done = current_user.completed_todos
|
||||
@done_today = @done.completed_within Time.zone.now - 1.day
|
||||
@done_this_week = @done.completed_within Time.zone.now - 1.week
|
||||
|
|
@ -516,7 +516,7 @@ class TodosController < ApplicationController
|
|||
end
|
||||
|
||||
def completed_archive
|
||||
@page_title = "TRACKS::Archived completed tasks"
|
||||
@page_title = t('todos.archived_tasks_title')
|
||||
@done = current_user.completed_todos
|
||||
@count = @done.size
|
||||
@done_archive = @done.completed_more_than Time.zone.now - 28.days
|
||||
|
|
@ -524,7 +524,7 @@ class TodosController < ApplicationController
|
|||
|
||||
def list_deferred
|
||||
@source_view = 'deferred'
|
||||
@page_title = "TRACKS::Tickler"
|
||||
@page_title = t('todos.deferred_tasks_title')
|
||||
|
||||
@contexts_to_show = @contexts = current_user.contexts.find(:all)
|
||||
|
||||
|
|
@ -561,7 +561,7 @@ class TodosController < ApplicationController
|
|||
def tag
|
||||
@source_view = params['_source_view'] || 'tag'
|
||||
@tag_name = params[:name]
|
||||
@page_title = "TRACKS::Tagged with \'#{@tag_name}\'"
|
||||
@page_title = t('todos.tagged_page_title', :tag_name => @tag_name)
|
||||
|
||||
# mobile tags are routed with :name ending on .m. So we need to chomp it
|
||||
@tag_name = @tag_name.chomp('.m') if mobile?
|
||||
|
|
@ -645,7 +645,7 @@ class TodosController < ApplicationController
|
|||
|
||||
def calendar
|
||||
@source_view = params['_source_view'] || 'calendar'
|
||||
@page_title = "TRACKS::Calendar"
|
||||
@page_title = t('todos.calendar_page_title')
|
||||
|
||||
@projects = current_user.projects.find(:all)
|
||||
|
||||
|
|
@ -778,24 +778,24 @@ class TodosController < ApplicationController
|
|||
condition_builder.add 'todos.state = ?', 'active'
|
||||
end
|
||||
|
||||
@title = "Tracks - Next Actions"
|
||||
@description = "Filter: "
|
||||
@title = t('todos.next_actions_title')
|
||||
@description = t('todos.next_actions_description')
|
||||
|
||||
if params.key?('due')
|
||||
due_within = params['due'].to_i
|
||||
due_within_when = Time.zone.now + due_within.days
|
||||
condition_builder.add('todos.due <= ?', due_within_when)
|
||||
due_within_date_s = due_within_when.strftime("%Y-%m-%d")
|
||||
@title << " due today" if (due_within == 0)
|
||||
@title << " due within a week" if (due_within == 6)
|
||||
@description << " with a due date #{due_within_date_s} or earlier"
|
||||
@title << t('todos.next_actions_title_additions.due_today') if (due_within == 0)
|
||||
@title << t('todos.next_actions_title_additions.due_within_a_week') if (due_within == 6)
|
||||
@description << t('todos.next_actions_description_additions.due_date', :due_date => due_within_date_s)
|
||||
end
|
||||
|
||||
if params.key?('done')
|
||||
done_in_last = params['done'].to_i
|
||||
condition_builder.add('todos.completed_at >= ?', Time.zone.now - done_in_last.days)
|
||||
@title << " actions completed"
|
||||
@description << " in the last #{done_in_last.to_s} days"
|
||||
@title << t('todos.next_actions_title_additions.completed')
|
||||
@description << t('todos.next_actions_description_additions.completed', :count => done_in_last.to_s)
|
||||
end
|
||||
|
||||
if params.key?('tag')
|
||||
|
|
@ -813,16 +813,16 @@ class TodosController < ApplicationController
|
|||
end
|
||||
|
||||
def with_parent_resource_scope(&block)
|
||||
@feed_title = "Actions "
|
||||
@feed_title = t('todos.feed_title')
|
||||
if (params[:context_id])
|
||||
@context = current_user.contexts.find_by_params(params)
|
||||
@feed_title = @feed_title + "in context '#{@context.name}'"
|
||||
@feed_title = @feed_title + t('todos.feed_title_in_context', :context => @context.name)
|
||||
Todo.send :with_scope, :find => {:conditions => ['todos.context_id = ?', @context.id]} do
|
||||
yield
|
||||
end
|
||||
elsif (params[:project_id])
|
||||
@project = current_user.projects.find_by_params(params)
|
||||
@feed_title = @feed_title + "in project '#{@project.name}'"
|
||||
@feed_title = @feed_title + t('todos.feed_title_in_project', :project => @project.name)
|
||||
@project_feed = true
|
||||
Todo.send :with_scope, :find => {:conditions => ['todos.project_id = ?', @project.id]} do
|
||||
yield
|
||||
|
|
@ -839,9 +839,9 @@ class TodosController < ApplicationController
|
|||
end
|
||||
if TodosController.is_feed_request(request) && @description
|
||||
if params.key?('limit')
|
||||
@description << "Lists the last #{params['limit']} incomplete next actions"
|
||||
@description << t('todos.list_incomplete_next_actions_with_limit', :count => params['limit'])
|
||||
else
|
||||
@description << "Lists incomplete next actions"
|
||||
@description << t('todos.list_incomplete_next_actions')
|
||||
end
|
||||
end
|
||||
else
|
||||
|
|
@ -971,7 +971,7 @@ class TodosController < ApplicationController
|
|||
|
||||
def render_todos_html
|
||||
lambda do
|
||||
@page_title = "TRACKS::List tasks"
|
||||
@page_title = t('todos.task_list_title')
|
||||
|
||||
# If you've set no_completed to zero, the completed items box isn't shown
|
||||
# on the home page
|
||||
|
|
@ -996,7 +996,7 @@ class TodosController < ApplicationController
|
|||
|
||||
def render_todos_mobile
|
||||
lambda do
|
||||
@page_title = "All actions"
|
||||
@page_title = t('todos.mobile_todos_page_title')
|
||||
@home = true
|
||||
cookies[:mobile_url]= { :value => request.request_uri, :secure => SITE_CONFIG['secure_cookies']}
|
||||
determine_down_count
|
||||
|
|
@ -1026,15 +1026,15 @@ class TodosController < ApplicationController
|
|||
def todo_feed_content
|
||||
lambda do |i|
|
||||
item_notes = sanitize(markdown( i.notes )) if i.notes?
|
||||
due = "<div>Due: #{format_date(i.due)}</div>\n" if i.due?
|
||||
done = "<div>Completed: #{format_date(i.completed_at)}</div>\n" if i.completed?
|
||||
due = "<div>#{t('todos.feeds.due', :date => format_date(i.due))}</div>\n" if i.due?
|
||||
done = "<div>#{t('todos.feeds.completed', :date => format_date(i.completed_at))}</div>\n" if i.completed?
|
||||
context_link = "<a href=\"#{ context_url(i.context) }\">#{ i.context.name }</a>"
|
||||
if i.project_id?
|
||||
project_link = "<a href=\"#{ project_url(i.project) }\">#{ i.project.name }</a>"
|
||||
else
|
||||
project_link = "<em>none</em>"
|
||||
project_link = "<em>#{t('common.none')}</em>"
|
||||
end
|
||||
"#{done||''}#{due||''}#{item_notes||''}\n<div>Project: #{project_link}</div>\n<div>Context: #{context_link}</div>"
|
||||
"#{done||''}#{due||''}#{item_notes||''}\n<div>#{t('common.project')}: #{project_link}</div>\n<div>#{t('common.context')}: #{context_link}</div>"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -35,15 +35,15 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
if User.no_users_yet?
|
||||
@page_title = "TRACKS::Sign up as the admin user"
|
||||
@heading = "Welcome to TRACKS. To get started, please create an admin account:"
|
||||
@page_title = t('users.new_user_title')
|
||||
@heading = t('users.first_user_heading')
|
||||
@user = get_new_user
|
||||
elsif (@user && @user.is_admin?) || SITE_CONFIG['open_signups']
|
||||
@page_title = "TRACKS::Sign up a new user"
|
||||
@heading = "Sign up a new user:"
|
||||
@page_title = t('users.new_user_title')
|
||||
@heading = t('users.new_user_heading')
|
||||
@user = get_new_user
|
||||
else # all other situations (i.e. a non-admin is logged in, or no one is logged in, but we have some users)
|
||||
@page_title = "TRACKS::No signups"
|
||||
@page_title = t('users.no_signups_title')
|
||||
@admin_email = User.find_admin.preference.admin_email
|
||||
render :action => "nosignup", :layout => "login"
|
||||
return
|
||||
|
|
@ -66,7 +66,7 @@ class UsersController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html do
|
||||
unless User.no_users_yet? || (@user && @user.is_admin?) || SITE_CONFIG['open_signups']
|
||||
@page_title = "No signups"
|
||||
@page_title = t('users.no_signups_title')
|
||||
@admin_email = User.find_admin.preference.admin_email
|
||||
render :action => "nosignup", :layout => "login"
|
||||
return
|
||||
|
|
@ -98,10 +98,10 @@ class UsersController < ApplicationController
|
|||
user.is_admin = true if first_user_signing_up
|
||||
if user.save
|
||||
@user = User.authenticate(user.login, params['user']['password'])
|
||||
@user.create_preference
|
||||
@user.create_preference({:locale => I18n.locale})
|
||||
@user.save
|
||||
session['user_id'] = @user.id if first_user_signing_up
|
||||
notify :notice, "Signup successful for user #{@user.login}."
|
||||
notify :notice, t('users.signup_successful', :username => @user.login)
|
||||
redirect_back_or_home
|
||||
end
|
||||
return
|
||||
|
|
@ -121,7 +121,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
user.password_confirmation = params[:request][:password]
|
||||
if user.save
|
||||
render :text => "User created.", :status => 200
|
||||
render :text => t('users.user_created'), :status => 200
|
||||
else
|
||||
render_failure user.errors.to_xml
|
||||
end
|
||||
|
|
@ -139,9 +139,9 @@ class UsersController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.html do
|
||||
if @saved
|
||||
notify :notice, "Successfully deleted user #{@deleted_user.login}", 2.0
|
||||
notify :notice, t('users.successfully_deleted_user', :username => @deleted_user.login), 2.0
|
||||
else
|
||||
notify :error, "Failed to delete user #{@deleted_user.login}", 2.0
|
||||
notify :error, t('users.failed_to_delete_user', :username => @deleted_user.login), 2.0
|
||||
end
|
||||
redirect_to users_url
|
||||
end
|
||||
|
|
@ -152,12 +152,12 @@ class UsersController < ApplicationController
|
|||
|
||||
|
||||
def change_password
|
||||
@page_title = "TRACKS::Change password"
|
||||
@page_title = t('users.change_password_title')
|
||||
end
|
||||
|
||||
def update_password
|
||||
@user.change_password(params[:updateuser][:password], params[:updateuser][:password_confirmation])
|
||||
notify :notice, "Password updated."
|
||||
notify :notice, t('users.password_updated')
|
||||
redirect_to preferences_path
|
||||
rescue Exception => error
|
||||
notify :error, error.message
|
||||
|
|
@ -165,7 +165,7 @@ class UsersController < ApplicationController
|
|||
end
|
||||
|
||||
def change_auth_type
|
||||
@page_title = "TRACKS::Change authentication type"
|
||||
@page_title = t('users.change_auth_type_title')
|
||||
end
|
||||
|
||||
def update_auth_type
|
||||
|
|
@ -177,10 +177,10 @@ class UsersController < ApplicationController
|
|||
@user.auth_type = 'open_id'
|
||||
@user.open_id_url = identity_url
|
||||
if @user.save
|
||||
notify :notice, "You have successfully verified #{identity_url} as your identity and set your authentication type to Open ID."
|
||||
notify :notice, t('users.openid_url_verified', :url => identity_url)
|
||||
else
|
||||
debugger
|
||||
notify :warning, "You have successfully verified #{identity_url} as your identity but there was a problem saving your authentication preferences."
|
||||
notify :warning, t('users.openid_ok_pref_failed', :url => identity_url)
|
||||
end
|
||||
redirect_to preferences_path
|
||||
else
|
||||
|
|
@ -192,10 +192,10 @@ class UsersController < ApplicationController
|
|||
end
|
||||
@user.auth_type = params[:user][:auth_type]
|
||||
if @user.save
|
||||
notify :notice, "Authentication type updated."
|
||||
notify :notice, t('users.auth_type_updated')
|
||||
redirect_to preferences_path
|
||||
else
|
||||
notify :warning, "There was a problem updating your authentication type: #{ @user.errors.full_messages.join(', ')}"
|
||||
notify :warning, t('users.auth_type_update_error', :error_messages => @user.errors.full_messages.join(', '))
|
||||
redirect_to :action => 'change_auth_type'
|
||||
end
|
||||
end
|
||||
|
|
@ -203,7 +203,7 @@ class UsersController < ApplicationController
|
|||
def refresh_token
|
||||
@user.generate_token
|
||||
@user.save!
|
||||
notify :notice, "New token successfully generated"
|
||||
notify :notice, t('users.new_token_generated')
|
||||
redirect_to preferences_path
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue