fix #1101. Most strings were pushed into html attributes. The remaining are generated from the layout into an array

This commit is contained in:
Reinier Balt 2011-02-09 20:41:34 +01:00
parent e528af30a6
commit f2760ed7de
21 changed files with 147 additions and 76 deletions

View file

@ -129,30 +129,6 @@ module ApplicationHelper
{:id => "link_edit_#{dom_id(note)}", :class => "note_edit_settings"})
end
def link_to_delete_project(project, descriptor = sanitize(project.name))
link_to(
descriptor,
project_path(project, :format => 'js'),
{:id => "delete_project_#{project.id}", :class => "delete_project_button", :title => "#{t('projects.delete_project_title')} '#{project.name}'"}
)
end
def link_to_delete_context(context, descriptor = sanitize(context.name))
link_to(
descriptor,
context_path(context, :format => 'js'),
{:id => "delete_context_#{context.id}", :class => "delete_context_button", :title => t('contexts.delete_context_confirmation', :name => context.name)}
)
end
def link_to_delete_note(note, descriptor = sanitize(note.id.to_s))
link_to(
descriptor,
note_path(note, :format => 'js'),
{:id => "delete_note_#{note.id}", :class => "delete_note_button", :title => "delete the note '#{note.id}'"}
)
end
def link_to_project_mobile(project, accesskey, descriptor = sanitize(project.name))
link_to( descriptor, project_path(project, :format => 'm'), {:title => "View project: #{project.name}", :accesskey => accesskey} )
end
@ -263,4 +239,24 @@ module ApplicationHelper
end
end
def generate_i18n_strings
js = ""
js << "i18n = new Array();\n"
%w{
shared.toggle_multi shared.toggle_multi_title
shared.hide_form shared.hide_action_form_title
shared.toggle_single shared.toggle_single_title
projects.hide_form projects.hide_form_title
projects.show_form projects.show_form_title
contexts.hide_form contexts.hide_form_title
contexts.show_form contexts.show_form_title
contexts.new_context_pre contexts.new_context_post
common.cancel common.ok
common.ajaxError
}.each do |s|
js << "i18n['#{s}'] = \"#{t(s)}\";\n"
end
return js
end
end

View file

@ -9,4 +9,17 @@ module ContextsHelper
}
end
def link_to_delete_context(context, descriptor = sanitize(context.name))
link_to(
descriptor,
context_path(context, :format => 'js'),
{
:id => "delete_context_#{context.id}",
:class => "delete_context_button",
:x_confirm_message => t('contexts.delete_context_confirmation', :name => context.name),
:title => t('contexts.delete_context_title')
}
)
end
end

View file

@ -6,4 +6,14 @@ module NotesHelper
def rendered_note(note)
sanitize(textilize_without_paragraph(note.body))
end
def link_to_delete_note(note, descriptor = sanitize(note.id.to_s))
link_to(
descriptor,
note_path(note, :format => 'js'),
{:id => "delete_note_#{note.id}", :class => "delete_note_button",
:title => t('notes.delete_note_title', :id => note.id), :x_confirm_message => t('notes.delete_note_confirm', :id => note.id)}
)
end
end

View file

@ -44,5 +44,18 @@ module ProjectsHelper
end
html
end
def link_to_delete_project(project, descriptor = sanitize(project.name))
link_to(
descriptor,
project_path(project, :format => 'js'),
{
:id => "delete_project_#{project.id}",
:class => "delete_project_button",
:x_confirm_message => t('projects.delete_project_confirmation', :name => project.name),
:title => t('projects.delete_project_title')
}
)
end
end

View file

@ -13,7 +13,7 @@ module RecurringTodosHelper
def recurring_todo_remote_delete_icon
link_to( image_tag_for_delete,
recurring_todo_path(@recurring_todo), :id => "delete_icon_"+@recurring_todo.id.to_s,
:class => "icon delete_icon", :title => t('todos.delete_recurring_action', :description => @recurring_todo.description))
:class => "icon delete_icon", :title => t('todos.delete_recurring_action_title'), :x_confirm_message => t('todos.delete_recurring_action_confirm', :description => @recurring_todo.description))
end
def recurring_todo_remote_star_icon

View file

@ -20,7 +20,8 @@ module TodosHelper
{:controller => 'todos', :action => 'destroy', :id => todo.id},
:class => "icon_delete_item",
:id => "delete_#{dom_id(todo)}",
:title => t('todos.confirm_delete', :description => todo.description));
:x_confirm_message => t('todos.confirm_delete', :description => todo.description),
:title => t('todos.delete_action'));
end
def remote_defer_menu_item(days, todo)

View file

@ -1,7 +1,7 @@
<div id="context_new_container">
<div id="toggle_context_new" class="hide_form">
<a title="<%= t('contexts.hide_form_link_title') %>" accesskey="n">&laquo; <%= t('contexts.hide_form') %></a>
<div id="toggle_context_link" class="hide_form">
<a id="toggle_context_new" href="#" title="<%= t('contexts.hide_form_title') %>" accesskey="n"><%= t('contexts.hide_form') %></a>
</div>
<div id="context_new" class="context_new" style="display:block">

View file

@ -27,6 +27,7 @@
setup_periodic_check("<%=url_for(:controller => "login", :action => "check_expiry")%>", 5*60);
<% end -%>
setup_periodic_check("<%=check_deferred_todos_path(:format => 'js')%>", 10*60, 'POST');
<%= generate_i18n_strings %>
</script>
<link rel="shortcut icon" href="<%= url_for(:controller => 'favicon.ico') %>" />
<%= auto_discovery_link_tag(:rss, {:controller => "todos", :action => "index", :format => 'rss', :token => "#{current_user.token}"}, {:title => t('layouts.next_actions_rss_feed')}) %>

View file

@ -1,7 +1,7 @@
<div id="project_new_project_container">
<div id="toggle_project_link" class="hide_form">
<a id="toggle_project_new" href="#" title="<%= t('projects.hide_new_project_form') %>" accesskey="n">&laquo; <%= t('projects.hide_form') %></a>
<a id="toggle_project_new" href="#" title="<%= t('projects.hide_form_title') %>" accesskey="n">&laquo; <%= t('projects.hide_form') %></a>
</div>
<div id="project_new" class="project_new" style="display:block">

View file

@ -18,7 +18,7 @@ suppress_edit_button ||= false
<div class="buttons">
<span class="grey"><%= project.current_state.to_s.upcase %></span>
<%= link_to_delete_project(project, image_tag( "blank.png", :title => t('projects.delete_project'), :class=>"delete_item")) %>
<%= link_to_delete_project(project, image_tag( "blank.png", :title => t('projects.delete_project_title'), :class=>"delete_item")) %>
<%= suppress_edit_button ? "" : link_to_edit_project(project, image_tag( "blank.png", :title => t('projects.edit_project_title'), :class=>"edit_item")) %>
</div>

View file

@ -3,10 +3,10 @@
<div class="menu_sort"><span class="sort_separator"><%= t('common.sort.sort') %>&nbsp;</span>
<div class="alpha_sort">
<%= link_to("Alphabetically", alphabetize_projects_path(:state => state),
:id => "#{state}_alphabetize_link", :class => "alphabetize_link", :title => t('common.sort.alphabetically_title')) %>
:id => "#{state}_alphabetize_link", :class => "alphabetize_link", :title => t('common.sort.alphabetically_title'), :x_confirm_message => t('common.sort.alphabetically_confirm')) %>
</div><span class="sort_separator">&nbsp;|&nbsp;</span><div class="tasks_sort">
<%= link_to("By number of tasks", actionize_projects_path(:state => state),
:id => "#{state}_actionize_link", :class => "actionize_link", :title => t('common.sort.by_task_count_title')) %>
:id => "#{state}_actionize_link", :class => "actionize_link", :title => t('common.sort.by_task_count_title'), :x_confirm_message => t('common.sort.by_task_count_title_confirm')) %>
</div>
</div>

View file

@ -7,7 +7,7 @@
<div id="todo_new_action_container">
<div id="toggle_forms" class="toggle_forms">
<a title="<%= t('shared.hide_action_form_title') %>" accesskey="n" href="#" id="toggle_action_new">&laquo; <%= t('shared.hide_form') %></a>
<a title="<%= t('shared.hide_action_form_title') %>" accesskey="n" href="#" id="toggle_action_new"><%= t('shared.hide_form') %></a> |
<a title="<%= t('shared.toggle_multi_title') %>" accesskey="m" href="#" id="toggle_multi"><%= t('shared.toggle_multi') %></a>
</div>

View file

@ -38,6 +38,7 @@ en:
update: "Update"
logout: "Logout"
cancel: "Cancel"
ok: "Ok"
project: "Project"
projects: "Projects"
context: "Context"
@ -55,12 +56,15 @@ en:
description: "Description"
notes: "Notes"
optional: "optional"
ajaxError: 'There was an error retrieving from server'
sort:
sort: "Sort"
alphabetically: "Alphabetically"
alphabetically_title: "Sort projects alphabetically"
alphabetically_confirm: "Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order."
by_task_count: "By number of tasks"
by_task_count_title: "Sort by number of tasks"
by_task_count_title_confirm: "Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order."
drag_handle: "DRAG"
contexts:
status_hidden: "Context is hidden"
@ -73,14 +77,19 @@ en:
add_context: "Add Context"
context_hide: "Hide from front page?"
hide_form: "Hide form"
hide_form_title: "Hide new context form"
show_form: "Create a new context"
show_form_title: "Add a context"
visible_contexts: "Visible contexts"
hidden_contexts: "Hidden contexts"
context_deleted: "Deleted context '%{name}'"
no_contexts_hidden: "Currently there are no hidden contexts"
no_contexts_active: "Currently there are no active contexts"
hide_form_link_title: "Hide new context form"
delete_context: "Delete context"
delete_context_title: "Delete context"
delete_context_confirmation: "Are you sure that you want to delete the context '%{name}'? Be aware that this will also delete all (repeating) actions in this context!"
new_context_pre: "New context '"
new_context_post: "' will be also created. Are you sure?"
edit_context: "Edit context"
data:
import_errors: "Some errors occurred during import"
@ -194,6 +203,8 @@ en:
delete_item_title: "Delete item"
show_note_title: "Show note"
deleted_note: "Deleted note '%{id}'"
delete_note_title: "Delete the note '%{id}'"
delete_note_confirm: "Are you sure that you want to delete the note '%{id}'?"
no_notes_available: "Currently there are no notes: add notes to projects from individual project pages."
preferences:
title: "Your preferences"
@ -241,11 +252,14 @@ en:
default_context: "The default context for this project is %{context}"
project_state: "Project is %{state}."
no_projects: "Currently there are no projects"
hide_new_project_form: "Hide new project form"
hide_form_title: "Hide new project form"
hide_form: "Hide form"
show_form_title: "Create a new project"
show_form: "Add a project"
add_project: "Add Project"
to_new_project_page: "Take me to the new project page"
delete_project_title: "delete the project"
delete_project_title: "Delete the project"
delete_project_confirmation: "Are you sure that you want to delete the project '%{name}'?"
delete_project: "Delete project"
edit_project_title: "Edit project"
states:
@ -269,6 +283,8 @@ en:
hide_form: "Hide form"
toggle_multi_title: "Toggle single/multi new action form"
toggle_multi: "Add multiple next actions"
toggle_single: 'Add a next action'
toggle_single_title: 'Add a new next action'
separate_tags_with_commas: "separate with commas"
add_action: "Add action"
multiple_next_actions: "Multiple next actions (one on each line)"
@ -429,7 +445,8 @@ en:
show_option_always: "always"
show_days_before: "%{days} days before the todo is due"
from_tickler: "the date todo comes from tickler (no due date set)"
delete_recurring_action: "delete the recurring action '%{description}'"
delete_recurring_action_confirm: "Are you sure that you want to delete the recurring action '%{description}'?"
delete_recurring_action_title: "Delete the recurring action"
star_action_with_description: "star the action '%{description}'"
star_action: "Star this action"
delete_action: "Delete action"

View file

@ -80,3 +80,12 @@ Feature: Manage the list of contexts
Scenario: I can drag and drop to order the contexts
# TODO: pending scenario
Given this is a pending scenario
@selenium @wip
Scenario: Hiding and unhiding the new project form
When I go to the contexts page
Then the new context form should be visible
When I follow "Hide form"
Then the new context form should not be visible
When I follow "Create a new context"
Then the new context form should be visible

View file

@ -12,8 +12,13 @@ Feature: Edit a next action from every page
Scenario: I can toggle the star of a todo
Given this is a pending scenario
@selenium @wip
Scenario: I can delete a todo
Given this is a pending scenario
Given I have a todo with description "delete me" in the context "@home"
When I go to the home page
Then I should see "delete me"
And I delete the todo
Then I should not see "delete me"
Scenario: Removing the last todo in context will hide context # delete, edit
Given this is a pending scenario

View file

@ -72,9 +72,9 @@ Feature: Manage the list of projects
Scenario: Hiding and unhiding the new project form
When I go to the projects page
Then the new project form should be visible
When I follow "« Hide form"
When I follow "Hide form"
Then the new project form should not be visible
When I follow "Create a new project »"
When I follow "Create a new project"
Then the new project form should be visible
@selenium

View file

@ -15,7 +15,7 @@ Feature: Add new next action from every page
Scenario Outline: I can hide the input form for single next action on a page
When I <action> the <page>
Then the single action form should be visible
When I follow "« Hide form"
When I follow "Hide form"
Then the single action form should not be visible
Scenarios:
@ -32,7 +32,7 @@ Feature: Add new next action from every page
Then the single action form should be visible
When I follow "Add multiple next actions"
Then the multiple action form should be visible
When I follow "« Hide form"
When I follow "Hide form"
Then the single action form should not be visible
And the multiple action form should not be visible
@ -48,11 +48,11 @@ Feature: Add new next action from every page
Scenario Outline: I can hide the input form and then choose both input forms
When I <action> the <page>
Then the single action form should be visible
When I follow "« Hide form"
When I follow "Hide form"
Then the single action form should not be visible
When I follow "Add multiple next actions"
Then the multiple action form should be visible
When I follow "« Hide form"
When I follow "Hide form"
Then the single action form should not be visible
And the multiple action form should not be visible
@ -71,7 +71,7 @@ Feature: Add new next action from every page
When I follow "Add multiple next actions"
Then the single action form should not be visible
And the multiple action form should be visible
When I follow "Add single next action"
When I follow "Add a next action"
Then the single action form should be visible
And the multiple action form should not be visible

View file

@ -61,7 +61,7 @@ end
When /^I edit the context name in place to be "([^\"]*)"$/ do |new_context_name|
selenium.click "context_name"
fill_in "value", :with => new_context_name
click_button "OK"
click_button "Ok"
end
Then /^I should see the context name is "([^\"]*)"$/ do |context_name|

View file

@ -104,7 +104,7 @@ end
When /^I edit the project name in place to be "([^"]*)"$/ do |new_project_name|
selenium.click "project_name"
fill_in "value", :with => new_project_name
click_button "OK"
click_button "Ok"
end
When /^I edit the project state of "([^"]*)" to "([^"]*)"$/ do |project_name, state_name|

View file

@ -243,7 +243,7 @@ Then /^the container for the context "([^"]*)" should not be visible$/ do |conte
end
Then /^a confirmation for adding a new context "([^"]*)" should be asked$/ do |context_name|
selenium.get_confirmation.should == "New context \"#{context_name}\" will be also created. Are you sure?"
selenium.get_confirmation.should == "New context '#{context_name}' will be also created. Are you sure?"
end
Then /^I should see "([^"]*)" in the deferred container$/ do |todo_description|

View file

@ -8,7 +8,7 @@ var TracksForm = {
toggleLink.text(showLinkText).attr('title', showLinkTitle);
}
else {
toggleLidefault_ajax_optionsnk.text(hideLinkText).attr('title', hideLinkTitle);
toggleLink.text(hideLinkText).attr('title', hideLinkTitle);
$('#'+formId+' input:text:first').focus();
}
toggleLink.parent().toggleClass('hide_form');
@ -46,12 +46,12 @@ var TracksForm = {
if ($("#todo_multi_add").is(':visible')) { /* hide multi next action form first */
$('#todo_new_action').show();
$('#todo_multi_add').hide();
$('a#toggle_multi').text("Add multiple next actions");
$('a#toggle_multi').text(i18n['shared.toggle_multi']);
}
TracksForm.toggle('toggle_action_new', 'todo_new_action', 'todo-form-new-action',
'« Hide form', 'Hide next action form',
'Add a next action »', 'Add a next action');
i18n['shared.hide_form'], i18n['shared.hide_action_form_title'],
i18n['shared.toggle_single'], i18n['shared.toggle_single_title']);
});
/* toggle new todo form for multi edit */
@ -59,13 +59,13 @@ var TracksForm = {
if ($("#todo_multi_add").is(':visible')) {
$('#todo_new_action').show();
$('#todo_multi_add').hide();
$('a#toggle_multi').text("Add multiple next actions");
$('a#toggle_multi').text(i18n['shared.toggle_multi']);
}
else {
$('#todo_new_action').hide();
$('#todo_multi_add').show();
$('a#toggle_multi').text("Add single next action");
$('a#toggle_action_new').text('« Hide form');
$('a#toggle_multi').text(i18n['shared.toggle_single']);
$('a#toggle_action_new').text(i18n['shared.hide_form']);
}
});
@ -74,14 +74,15 @@ var TracksForm = {
$(this).prev().val('');
});
/* behavior for delete icon */
/* behavior for delete icon. DEAD CODE??? */
$('.item-container a.delete_icon').live('click', function(evt){
evt.preventDefault();
params = {};
if(typeof(TAG_NAME) !== 'undefined'){
params._tag_name = TAG_NAME;
}
if(confirm("Are you sure that you want to "+this.title+"?")){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
itemContainer = $(this).parents(".item-container");
itemContainer.block({
message: null
@ -93,7 +94,7 @@ var TracksForm = {
}
});
/* behavior for edit icon */
/* behavior for edit icon DEAD CODE???*/
$('.item-container a.edit_icon').live('click', function(evt){
evt.preventDefault();
params = {};
@ -318,7 +319,7 @@ var TodoItems = {
for (i=0; i<contexts.length; i++)
if (contexts[i].value == givenContextName) return true;
}
return confirm('New context "' + givenContextName + '" will be also created. Are you sure?');
return confirm(i18n['contexts.new_context_pre'] + givenContextName + i18n['contexts.new_context_post']);
},
setup_behavior: function() {
/* show the notes of a todo */
@ -350,9 +351,10 @@ var TodoItems = {
return false;
});
/* delete button to delete a project from the list */
/* delete button to delete a todo or recurring_todo from the list */
$('.item-container a.icon_delete_item').live('click', function(evt){
if(confirm(this.title)){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
delete_with_ajax_and_block_element(this.href, $(this).parents('.project'));
}
return false;
@ -434,13 +436,14 @@ var ProjectListPage = {
/* in-place edit of project name */
$('h2#project_name').editable(ProjectListPage.save_project_name, {
style: 'padding:0px',
submit: "OK",
cancel: "CANCEL"
submit: i18n['common.ok'],
cancel: i18n['common.cancel']
});
/* alphabetize project list */
$('.alphabetize_link').live('click', function(evt){
if(confirm('Are you sure that you want to sort these projects alphabetically? This will replace the existing sort order.')){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
post_with_ajax_and_block_element(this.href, $(this).parents('.alpha_sort'));
}
return false;
@ -448,7 +451,8 @@ var ProjectListPage = {
/* sort by number of actions */
$('.actionize_link').click(function(evt){
if(confirm('Are you sure that you want to sort these projects by the number of tasks? This will replace the existing sort order.')){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
post_with_ajax_and_block_element(this.href, $(this).parents('.tasks_sort'));
}
return false;
@ -456,7 +460,8 @@ var ProjectListPage = {
/* delete button to delete a project from the list */
$('a.delete_project_button').live('click', function(evt){
if(confirm("Are you sure that you want to "+this.title+"?")){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
delete_with_ajax_and_block_element(this.href, $(this).parents('.project'));
}
return false;
@ -483,8 +488,8 @@ var ProjectListPage = {
/* toggle new project form */
$('#toggle_project_new').click(function(evt){
TracksForm.toggle('toggle_project_new', 'project_new', 'project-form',
'« Hide form', 'Hide new project form',
'Create a new project »', 'Add a project');
i18n['projects.hide_form'], i18n['projects.hide_form_title'],
i18n['projects.show_form'], i18n['projects.show_form_title']);
});
/* make the three lists of project sortable */
@ -532,14 +537,14 @@ var ContextListPage = {
/* in place edit of context name */
$('div.context span#context_name').editable(ContextListPage.save_context_name, {
style: 'padding:0px',
submit: "OK",
cancel: "CANCEL"
submit: i18n['common.ok'],
cancel: i18n['common.cancel']
});
/* delete a context using the x button */
$('a.delete_context_button').live('click', function(evt){
/* TODO: move from this.title to this.x-messsage or something similar */
if(confirm(this.title)){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
delete_with_ajax_and_block_element(this.href, $(this).parents('.context'));
}
return false;
@ -566,8 +571,8 @@ var ContextListPage = {
/* Contexts behavior */
$('#toggle_context_new').click(function(evt){
TracksForm.toggle('toggle_context_new', 'context_new', 'context-form',
'« Hide form', 'Hide new context form',
'Create a new context »', 'Add a context');
i18n['contexts.hide_form'], i18n['contexts.hide_form_title'],
i18n['contexts.show_form'], i18n['contexts.show_form_title']);
});
/* make the two state lists of context sortable */
@ -626,7 +631,8 @@ var NotesPage = {
/* delete button for note */
$('a.delete_note_button').live('click', function(){
if(confirm("Are you sure that you want to "+this.title+"?")){
confirm_message = $(this).attr("x_confirm_message")
if(confirm(confirm_message)){
delete_with_ajax_and_block_element(this.href, $(this).parents('.project_notes'));
}
return false;
@ -789,7 +795,7 @@ function default_ajax_options_for_submit(ajax_type, element_to_block) {
enable_rich_interaction();
},
error: function(req, status) {
TracksPages.page_notify('error', 'There was an error retrieving from server: '+status, 8);
TracksPages.page_notify('error', i18n['common.ajaxError']+': '+status, 8);
}
}
if(typeof(TAG_NAME) !== 'undefined')