Get more i18n fixed in for he locale. Include fallback to en locale and include pluralization mechanism

This commit is contained in:
Reinier Balt 2012-04-16 13:17:59 +02:00
parent 3ba7daf1d0
commit e74f8842ae
20 changed files with 1839 additions and 1703 deletions

View file

@ -89,16 +89,16 @@ class ApplicationController < ActionController::Base
# is count and a string descriptor, correctly pluralised if there are no # is count and a string descriptor, correctly pluralised if there are no
# actions or multiple actions # actions or multiple actions
# #
def count_undone_todos_phrase(todos_parent, string="actions") def count_undone_todos_phrase(todos_parent)
count = count_undone_todos(todos_parent) count = count_undone_todos(todos_parent)
deferred_count = count_deferred_todos(todos_parent) deferred_count = count_deferred_todos(todos_parent)
if count == 0 && deferred_count > 0 if count == 0 && deferred_count > 0
word = deferred_count == 1 ? string.singularize : string.pluralize word = I18n.t('common.actions_midsentence', :count => deferred_count)
word = "deferred&nbsp;" + word word = I18n.t('common.deferred') + "&nbsp;" + word
deferred_count.to_s + "&nbsp;" + word return deferred_count.to_s + "&nbsp;" + word
else else
word = count == 1 ? string.singularize : string.pluralize word = I18n.t('common.actions_midsentence', :count => count)
count.to_s + "&nbsp;" + word return count.to_s + "&nbsp;" + word
end end
end end

View file

@ -98,17 +98,17 @@ module ApplicationHelper
# is count and a string descriptor, correctly pluralised if there are no # is count and a string descriptor, correctly pluralised if there are no
# actions or multiple actions # actions or multiple actions
# #
def count_undone_todos_phrase(todos_parent, string="actions") def count_undone_todos_phrase(todos_parent)
@controller.count_undone_todos_phrase(todos_parent, string) @controller.count_undone_todos_phrase(todos_parent)
end end
def count_undone_todos_phrase_text(todos_parent, string="actions") def count_undone_todos_phrase_text(todos_parent)
count_undone_todos_phrase(todos_parent, string).gsub("&nbsp;"," ") count_undone_todos_phrase(todos_parent).gsub("&nbsp;"," ")
end end
def count_undone_todos_and_notes_phrase(project, string="actions") def count_undone_todos_and_notes_phrase(project)
s = count_undone_todos_phrase(project, string) s = count_undone_todos_phrase(project)
s += ", #{pluralize(project.note_count, 'note')}" unless project.note_count == 0 s += ", #{t('common.note', :count => project.note_count)}" unless project.note_count == 0
s s
end end
@ -200,7 +200,7 @@ module ApplicationHelper
else else
return list.inject("") do |html, item| return list.inject("") do |html, item|
link = (item.class == "Project") ? link_to_project( item ) : link_to_context(item) link = (item.class == "Project") ? link_to_project( item ) : link_to_context(item)
html << content_tag(:li, link + " (" + count_undone_todos_phrase(item, I18n.t("common.actions_midsentence"))+")") html << content_tag(:li, link + " (" + count_undone_todos_phrase(item)+")")
end end
end end
end end

View file

@ -10,7 +10,7 @@ suppress_delete_button ||= false
<%= suppress_edit_button ? "" : link_to_edit_context(context, image_tag( "blank.png", :title => t('contexts.edit_context'), :class=>"edit_item")) -%> <%= suppress_edit_button ? "" : link_to_edit_context(context, image_tag( "blank.png", :title => t('contexts.edit_context'), :class=>"edit_item")) -%>
<%= suppress_drag_handle ? "" : image_tag('grip.png', :width => '7', :height => '16', :border => '0', :title => t('common.drag_handle'), :class => 'grip')-%> <%= suppress_drag_handle ? "" : image_tag('grip.png', :width => '7', :height => '16', :border => '0', :title => t('common.drag_handle'), :class => 'grip')-%>
<div class="context_description"> <div class="context_description">
<%= link_to_context( context ) %> <%= " (" + count_undone_todos_phrase(context,t('common.actions_midsentence')) + ")" %> <%= link_to_context( context ) %> <%= " (" + count_undone_todos_phrase(context) + ")" %>
</div> </div>
</div> </div>
<div id="<%= dom_id(context, 'edit') %>" class="edit-form" style="display:none;"> <div id="<%= dom_id(context, 'edit') %>" class="edit-form" style="display:none;">

View file

@ -1,2 +1,2 @@
<% context = mobile_context_listing -%> <% context = mobile_context_listing -%>
<div id="ctx"><%= link_to context.name, context_path(context, :format => 'm') %><%= " (" + count_undone_todos_phrase(context,"actions") + ")" %></div> <div id="ctx"><%= link_to context.name, context_path(context, :format => 'm') %><%= " (" + count_undone_todos_phrase(context) + ")" %></div>

View file

@ -12,7 +12,7 @@ suppress_delete_button ||= false
<div class="project_description"> <div class="project_description">
<span class="<%= needsreview_class( project ) %>"> <span class="<%= needsreview_class( project ) %>">
<%= link_to_project( project ) %> <%= link_to_project( project ) %>
<%= " (" + count_undone_todos_and_notes_phrase(project,t('common.actions_midsentence')) + ")" %> <%= " (" + count_undone_todos_and_notes_phrase(project) + ")" %>
</span> </span>
</div> </div>
</div> </div>

View file

@ -10,7 +10,7 @@
</div> </div>
<div class="container" id="completed_recurring_todos_container"> <div class="container" id="completed_recurring_todos_container">
<div class=add_note_link><%= link_to "Show all", done_recurring_todos_path%></div> <div class=add_note_link><%= link_to t('common.show_all'), done_recurring_todos_path%></div>
<h2><%= t('common.last') %> <%= t('todos.completed_recurring') %></h2> <h2><%= t('common.last') %> <%= t('todos.completed_recurring') %></h2>
<div id="completed_recurring_todos_container"> <div id="completed_recurring_todos_container">
<div id="completed-empty-nd" style="<%= @no_completed_recurring_todos ? 'display:block' : 'display:none'%>"> <div id="completed-empty-nd" style="<%= @no_completed_recurring_todos ? 'display:block' : 'display:none'%>">

View file

@ -9,7 +9,9 @@
<% <%
1.upto 5 do |i| 1.upto 5 do |i|
%><%=i-%> - %><%=i-%> -
<%= i <= @actions_per_context.size ? link_to(@actions_per_context[i-1]['name'], {:controller => "contexts", :action => "show", :id => @actions_per_context[i-1]['id']}) : "n/a"%> <%= i <= @actions_per_context.size ?
link_to(@actions_per_context[i-1]['name'], {:controller => "contexts", :action => "show", :id => @actions_per_context[i-1]['id']}) :
t('common.not_available_abbr')%>
( (
<%= i <= @actions_per_context.size ? @actions_per_context[i-1]['total'] : t('common.not_available_abbr')%> <%= i <= @actions_per_context.size ? @actions_per_context[i-1]['total'] : t('common.not_available_abbr')%>
) )
@ -23,7 +25,9 @@
<% <%
1.upto 5 do |i| 1.upto 5 do |i|
%><%=i-%> - %><%=i-%> -
<%= i <= @running_actions_per_context.size ? link_to(@running_actions_per_context[i-1]['name'], {:controller => "contexts", :action => "show", :id => @running_actions_per_context[i-1]['id']}) : "n/a"-%> <%= i <= @running_actions_per_context.size ?
link_to(@running_actions_per_context[i-1]['name'], {:controller => "contexts", :action => "show", :id => @running_actions_per_context[i-1]['id']}) :
t('common.not_available_abbr')-%>
( (
<%= i <= @running_actions_per_context.size ? @running_actions_per_context[i-1]['total'] : t('common.not_available_abbr')-%> <%= i <= @running_actions_per_context.size ? @running_actions_per_context[i-1]['total'] : t('common.not_available_abbr')-%>
) )

View file

@ -3,7 +3,7 @@
<% i=0 <% i=0
@projects_and_actions.each do |p| @projects_and_actions.each do |p|
i+=1 -%> i+=1 -%>
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id}%> (<%=p.count %> <%= t('common.actions_midsentence') %>) <br/> <%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id}%> (<%=p.count %> <%= t('common.actions_midsentence', :count => p.count) %>) <br/>
<% end <% end
if i < 10 if i < 10
i.upto 10 do |j| -%> i.upto 10 do |j| -%>
@ -18,7 +18,7 @@
<% i=0 <% i=0
@projects_and_actions_last30days.each do |p| @projects_and_actions_last30days.each do |p|
i+=1 -%> i+=1 -%>
<%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.count %> <%= t('common.actions_midsentence') %>) <br/> <%= i -%> - <%= link_to p.name, {:controller => "projects", :action => "show", :id => p.id} %> (<%=p.count %> <%= t('common.actions_midsentence', :count => p.count) %>) <br/>
<% end <% end
if i < 10 if i < 10
i.upto 10 do |j| -%> i.upto 10 do |j| -%>
@ -33,6 +33,6 @@
<% i=0 <% i=0
@projects_and_runtime.each do |id, name, days| @projects_and_runtime.each do |id, name, days|
i+=1 -%> i+=1 -%>
<%= i -%> - <%= link_to name, {:controller => "projects", :action => "show", :id => id} %> (<%=days %> <%= t('common.days_midsentence') %>) <br/> <%= i -%> - <%= link_to name, {:controller => "projects", :action => "show", :id => id} %> (<%=days %> <%= t('common.days_midsentence', :count => days) %>) <br/>
<% end -%> <% end -%>
</div> </div>

View file

@ -10,7 +10,7 @@
<%= link_to t.name, <%= link_to t.name,
{:controller => "todos", :action => "tag", :id => t.name}, {:controller => "todos", :action => "tag", :id => t.name},
{:style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min)/@tags_divisor).to_s + "pt", {:style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min)/@tags_divisor).to_s + "pt",
:title => t.count.to_s+" #{t('common.actions_midsentence')}"} :title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
-%> <% -%> <%
end end
end-%> end-%>
@ -28,7 +28,7 @@
<%= link_to t.name, <%= link_to t.name,
{:controller => "todos", :action => "tag", :id => t.name}, {:controller => "todos", :action => "tag", :id => t.name},
{:style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min_90days)/@tags_divisor_90days).to_s + "pt", {:style => "font-size: " + (9 + 2*(t.count.to_i-@tags_min_90days)/@tags_divisor_90days).to_s + "pt",
:title => t.count.to_s+" #{t('common.actions_midsentence')}"} :title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
-%> <% -%> <%
end end
end-%> end-%>

View file

@ -1,6 +1,6 @@
<div id="display_box"> <div id="display_box">
<div class="container"> <div class="container">
<div class=add_note_link><%= link_to "Show all", done_todos_path%></div> <div class=add_note_link><%= link_to t('common.show_all'), done_todos_path%></div>
<h2> <h2>
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.actions') %> <%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.actions') %>
</h2> </h2>
@ -12,15 +12,15 @@
</div> </div>
<div class="container"> <div class="container">
<div class=add_note_link><%= link_to "Show all", done_projects_path%></div> <div class=add_note_link><%= link_to t('common.show_all'), done_projects_path%></div>
<h2> <h2>
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.projects') %> <%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.projects') %>
</h2> </h2>
<% if @last_completed_projects.empty? -%> <% if @last_completed_projects.empty? -%>
<div class="message"><p><%= t('projects.no_last_completed_projects') %></p></div> <div class="message"><p><%= t('projects.no_last_completed_projects') %></p></div>
<% else -%> <% else -%>
<div id="list-completed-projects" class="project-list"> <div id="list-completed-projects" class="project-list">
<%= render :partial => '/projects/project_listing', <%= render :partial => '/projects/project_listing',
:collection => @last_completed_projects, :collection => @last_completed_projects,
:locals => {:suppress_drag_handle => true} :locals => {:suppress_drag_handle => true}
%> %>
@ -29,17 +29,15 @@
</div> </div>
<div class="container"> <div class="container">
<div class=add_note_link><%= link_to "Show all", done_recurring_todos_path%></div> <div class=add_note_link><%= link_to t('common.show_all'), done_recurring_todos_path%></div>
<h2> <h2>
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.recurring_todos') %> <%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.recurring_todos') %>
</h2> </h2>
<% if @last_completed_recurring_todos.empty? -%> <% if @last_completed_recurring_todos.empty? -%>
<div class="message"><p><%= t('projects.no_last_completed_recurring_todos') %></p></div> <div class="message"><p><%= t('projects.no_last_completed_recurring_todos') %></p></div>
<% else -%> <% else -%>
<%= render :partial => '/recurring_todos/recurring_todo', :collection => @last_completed_recurring_todos %> <%= render :partial => '/recurring_todos/recurring_todo', :collection => @last_completed_recurring_todos %>
<% end -%> <% end -%>
</div> </div>
</div>
</div><!-- End of display_box -->

View file

@ -3,7 +3,7 @@
suppress_project ||= false suppress_project ||= false
-%> -%>
<div class="container completed" id="completed_container"> <div class="container completed" id="completed_container">
<div class=add_note_link><%= link_to "Show all", determine_done_path%></div> <div class=add_note_link><%= link_to t('common.show_all'), determine_done_path%></div>
<h2> <h2>
<% if collapsible %> <% if collapsible %>
<a href="#" class="container_toggle" id="toggle_completed"><%= image_tag("collapse.png") %></a> <a href="#" class="container_toggle" id="toggle_completed"><%= image_tag("collapse.png") %></a>
@ -18,4 +18,4 @@
<%= render :partial => "todos/todo", :collection => completed, :locals => { :parent_container_type => "completed", :suppress_context => suppress_context, :suppress_project => suppress_project } %> <%= render :partial => "todos/todo", :collection => completed, :locals => { :parent_container_type => "completed", :suppress_context => suppress_context, :suppress_project => suppress_project } %>
</div> </div>
</div><!-- [end:next_actions] --> </div>

View file

@ -1,6 +1,6 @@
<% <%
paginate_options = { paginate_options = {
:class => :add_note_link, :class => :add_note_link,
:previous_label => '&laquo; '+ t('common.previous'), :previous_label => '&laquo; '+ t('common.previous'),
:next_label => t('common.next')+' &raquo;', :next_label => t('common.next')+' &raquo;',
:inner_window => 2 :inner_window => 2
@ -19,4 +19,4 @@
<%= will_paginate @done, paginate_options %> <%= will_paginate @done, paginate_options %>
</div><!-- End of display_box --> </div>

View file

@ -26,6 +26,6 @@
<% end -%> <% end -%>
</div> </div>
<p>You can see all completed actions <%= link_to "here", determine_all_done_path %></p> <p><%= t('todos.see_all_completed', :link => link_to(t("todos.all_completed_here"), determine_all_done_path)) %></p>
</div><!-- End of display_box --> </div>

View file

@ -0,0 +1,36 @@
module I18n::Backend::Pluralization
# rules taken from : http://www.gnu.org/software/hello/manual/gettext/Plural-forms.html
def pluralize(locale, entry, n)
return entry unless entry.is_a?(Hash) && n
if n == 0 && entry.has_key?(:zero)
key = :zero
else
key = case locale
when :pl # Polish
n==1 ? :one : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? :few : :other
when :cs, :sk # Czech, Slovak
n==1 ? :one : (n>=2 && n<=4) ? :few : :other
when :lt # Lithuanian
n%10==1 && n%100!=11 ? :one : n%10>=2 && (n%100<10 || n%100>=20) ? :few : :other
when :lv # Latvian
n%10==1 && n%100!=11 ? :one : n != 0 ? :few : :other
when :ru, :uk, :sr, :hr # Russian, Ukrainian, Serbian, Croatian
n%10==1 && n%100!=11 ? :one : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? :few : :other
when :sl # Slovenian
n%100==1 ? :one : n%100==2 ? :few : n%100==3 || n%100==4 ? :many : :other
when :ro # Romanian
n==1 ? :one : (n==0 || (n%100 > 0 && n%100 < 20)) ? :few : :other
when :gd # Gaeilge
n==1 ? :one : n==2 ? :two : :other;
# add another language if you like...
else
n==1 ? :one : :other # default :en
end
end
raise InvalidPluralizationData.new(entry, n) unless entry.has_key?(key)
entry[key]
end
end
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -92,7 +92,10 @@ en:
third: Third third: Third
recurring_todos: Repeating Actions recurring_todos: Repeating Actions
actions: Actions actions: Actions
actions_midsentence: actions actions_midsentence:
zero: actions
one: action
other: actions
add: Add add: Add
previous: Previous previous: Previous
show_all: Show all show_all: Show all
@ -132,6 +135,10 @@ en:
errors_with_fields: "There were problems with the following fields:" errors_with_fields: "There were problems with the following fields:"
next: Next next: Next
todo: todo todo: todo
note:
zero: no notes
one: 1 note
other: %{count} notes
context: Context context: Context
drag_handle: DRAG drag_handle: DRAG
description: Description description: Description
@ -143,7 +150,11 @@ en:
email: Email email: Email
search: Search search: Search
ajaxError: There was an error retrieving from server ajaxError: There was an error retrieving from server
days_midsentence: days days_midsentence:
zero: days
one: day
other: days
deferred: deferred
not_available_abbr: "n/a" not_available_abbr: "n/a"
data: data:
import_successful: Import was successful. import_successful: Import was successful.
@ -584,6 +595,8 @@ en:
add_new_recurring: Add a new recurring action add_new_recurring: Add a new recurring action
edit_recurring_todo: Edit repeating action edit_recurring_todo: Edit repeating action
no_incomplete_actions: There are no incomplete actions no_incomplete_actions: There are no incomplete actions
see_all_completed: You can see all completed actions %{link}
all_completed_here: here
notes: notes:
delete_confirmation: Are you sure that you want to delete the note '%{id}'? delete_confirmation: Are you sure that you want to delete the note '%{id}'?
delete_item_title: Delete item delete_item_title: Delete item

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff