mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Get more i18n fixed in for he locale. Include fallback to en locale and include pluralization mechanism
This commit is contained in:
parent
3ba7daf1d0
commit
e74f8842ae
20 changed files with 1839 additions and 1703 deletions
|
|
@ -89,16 +89,16 @@ class ApplicationController < ActionController::Base
|
|||
# is count and a string descriptor, correctly pluralised if there are no
|
||||
# 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)
|
||||
deferred_count = count_deferred_todos(todos_parent)
|
||||
if count == 0 && deferred_count > 0
|
||||
word = deferred_count == 1 ? string.singularize : string.pluralize
|
||||
word = "deferred " + word
|
||||
deferred_count.to_s + " " + word
|
||||
word = I18n.t('common.actions_midsentence', :count => deferred_count)
|
||||
word = I18n.t('common.deferred') + " " + word
|
||||
return deferred_count.to_s + " " + word
|
||||
else
|
||||
word = count == 1 ? string.singularize : string.pluralize
|
||||
count.to_s + " " + word
|
||||
word = I18n.t('common.actions_midsentence', :count => count)
|
||||
return count.to_s + " " + word
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -98,17 +98,17 @@ module ApplicationHelper
|
|||
# is count and a string descriptor, correctly pluralised if there are no
|
||||
# actions or multiple actions
|
||||
#
|
||||
def count_undone_todos_phrase(todos_parent, string="actions")
|
||||
@controller.count_undone_todos_phrase(todos_parent, string)
|
||||
def count_undone_todos_phrase(todos_parent)
|
||||
@controller.count_undone_todos_phrase(todos_parent)
|
||||
end
|
||||
|
||||
def count_undone_todos_phrase_text(todos_parent, string="actions")
|
||||
count_undone_todos_phrase(todos_parent, string).gsub(" "," ")
|
||||
def count_undone_todos_phrase_text(todos_parent)
|
||||
count_undone_todos_phrase(todos_parent).gsub(" "," ")
|
||||
end
|
||||
|
||||
def count_undone_todos_and_notes_phrase(project, string="actions")
|
||||
s = count_undone_todos_phrase(project, string)
|
||||
s += ", #{pluralize(project.note_count, 'note')}" unless project.note_count == 0
|
||||
def count_undone_todos_and_notes_phrase(project)
|
||||
s = count_undone_todos_phrase(project)
|
||||
s += ", #{t('common.note', :count => project.note_count)}" unless project.note_count == 0
|
||||
s
|
||||
end
|
||||
|
||||
|
|
@ -200,7 +200,7 @@ module ApplicationHelper
|
|||
else
|
||||
return list.inject("") do |html, 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
|
||||
|
|
|
|||
|
|
@ -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_drag_handle ? "" : image_tag('grip.png', :width => '7', :height => '16', :border => '0', :title => t('common.drag_handle'), :class => 'grip')-%>
|
||||
<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 id="<%= dom_id(context, 'edit') %>" class="edit-form" style="display:none;">
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
<% 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>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ suppress_delete_button ||= false
|
|||
<div class="project_description">
|
||||
<span class="<%= needsreview_class( project ) %>">
|
||||
<%= link_to_project( project ) %>
|
||||
<%= " (" + count_undone_todos_and_notes_phrase(project,t('common.actions_midsentence')) + ")" %>
|
||||
<%= " (" + count_undone_todos_and_notes_phrase(project) + ")" %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
</div>
|
||||
|
||||
<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>
|
||||
<div id="completed_recurring_todos_container">
|
||||
<div id="completed-empty-nd" style="<%= @no_completed_recurring_todos ? 'display:block' : 'display:none'%>">
|
||||
|
|
|
|||
|
|
@ -9,7 +9,9 @@
|
|||
<%
|
||||
1.upto 5 do |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')%>
|
||||
)
|
||||
|
|
@ -23,7 +25,9 @@
|
|||
<%
|
||||
1.upto 5 do |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')-%>
|
||||
)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
<% i=0
|
||||
@projects_and_actions.each do |p|
|
||||
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
|
||||
if i < 10
|
||||
i.upto 10 do |j| -%>
|
||||
|
|
@ -18,7 +18,7 @@
|
|||
<% i=0
|
||||
@projects_and_actions_last30days.each do |p|
|
||||
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
|
||||
if i < 10
|
||||
i.upto 10 do |j| -%>
|
||||
|
|
@ -33,6 +33,6 @@
|
|||
<% i=0
|
||||
@projects_and_runtime.each do |id, name, days|
|
||||
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 -%>
|
||||
</div>
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
<%= link_to 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",
|
||||
:title => t.count.to_s+" #{t('common.actions_midsentence')}"}
|
||||
:title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
|
||||
-%> <%
|
||||
end
|
||||
end-%>
|
||||
|
|
@ -28,7 +28,7 @@
|
|||
<%= link_to 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",
|
||||
:title => t.count.to_s+" #{t('common.actions_midsentence')}"}
|
||||
:title => t.count.to_s+" #{t('common.actions_midsentence', :count => t.count)}"}
|
||||
-%> <%
|
||||
end
|
||||
end-%>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
<div id="display_box">
|
||||
<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>
|
||||
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.actions') %>
|
||||
</h2>
|
||||
|
|
@ -12,15 +12,15 @@
|
|||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class=add_note_link><%= link_to "Show all", done_projects_path%></div>
|
||||
<h2>
|
||||
<div class=add_note_link><%= link_to t('common.show_all'), done_projects_path%></div>
|
||||
<h2>
|
||||
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.projects') %>
|
||||
</h2>
|
||||
</h2>
|
||||
<% if @last_completed_projects.empty? -%>
|
||||
<div class="message"><p><%= t('projects.no_last_completed_projects') %></p></div>
|
||||
<% else -%>
|
||||
<div id="list-completed-projects" class="project-list">
|
||||
<%= render :partial => '/projects/project_listing',
|
||||
<%= render :partial => '/projects/project_listing',
|
||||
:collection => @last_completed_projects,
|
||||
:locals => {:suppress_drag_handle => true}
|
||||
%>
|
||||
|
|
@ -29,17 +29,15 @@
|
|||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class=add_note_link><%= link_to "Show all", done_recurring_todos_path%></div>
|
||||
<h2>
|
||||
<div class=add_note_link><%= link_to t('common.show_all'), done_recurring_todos_path%></div>
|
||||
<h2>
|
||||
<%= t('common.last') %> <%= t('states.completed_plural' )%> <%= t('common.recurring_todos') %>
|
||||
</h2>
|
||||
</h2>
|
||||
<% if @last_completed_recurring_todos.empty? -%>
|
||||
<div class="message"><p><%= t('projects.no_last_completed_recurring_todos') %></p></div>
|
||||
<% else -%>
|
||||
<%= render :partial => '/recurring_todos/recurring_todo', :collection => @last_completed_recurring_todos %>
|
||||
<% end -%>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</div><!-- End of display_box -->
|
||||
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
suppress_project ||= false
|
||||
-%>
|
||||
<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>
|
||||
<% if collapsible %>
|
||||
<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 } %>
|
||||
</div>
|
||||
</div><!-- [end:next_actions] -->
|
||||
</div>
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<%
|
||||
paginate_options = {
|
||||
:class => :add_note_link,
|
||||
:class => :add_note_link,
|
||||
:previous_label => '« '+ t('common.previous'),
|
||||
:next_label => t('common.next')+' »',
|
||||
:inner_window => 2
|
||||
|
|
@ -19,4 +19,4 @@
|
|||
|
||||
<%= will_paginate @done, paginate_options %>
|
||||
|
||||
</div><!-- End of display_box -->
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@
|
|||
<% end -%>
|
||||
</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>
|
||||
|
|
|
|||
36
config/initializers/i18n-config.rb
Normal file
36
config/initializers/i18n-config.rb
Normal 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
|
|
@ -92,7 +92,10 @@ en:
|
|||
third: Third
|
||||
recurring_todos: Repeating Actions
|
||||
actions: Actions
|
||||
actions_midsentence: actions
|
||||
actions_midsentence:
|
||||
zero: actions
|
||||
one: action
|
||||
other: actions
|
||||
add: Add
|
||||
previous: Previous
|
||||
show_all: Show all
|
||||
|
|
@ -132,6 +135,10 @@ en:
|
|||
errors_with_fields: "There were problems with the following fields:"
|
||||
next: Next
|
||||
todo: todo
|
||||
note:
|
||||
zero: no notes
|
||||
one: 1 note
|
||||
other: %{count} notes
|
||||
context: Context
|
||||
drag_handle: DRAG
|
||||
description: Description
|
||||
|
|
@ -143,7 +150,11 @@ en:
|
|||
email: Email
|
||||
search: Search
|
||||
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"
|
||||
data:
|
||||
import_successful: Import was successful.
|
||||
|
|
@ -584,6 +595,8 @@ en:
|
|||
add_new_recurring: Add a new recurring action
|
||||
edit_recurring_todo: Edit repeating action
|
||||
no_incomplete_actions: There are no incomplete actions
|
||||
see_all_completed: You can see all completed actions %{link}
|
||||
all_completed_here: here
|
||||
notes:
|
||||
delete_confirmation: Are you sure that you want to delete the note '%{id}'?
|
||||
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
Loading…
Add table
Add a link
Reference in a new issue