i18n for will_paginate, including dynamically in outfits#edit

This commit is contained in:
Emi Matchu 2013-01-10 18:58:56 -06:00
parent 34e99bba72
commit 3b1ffe71a9
3 changed files with 59 additions and 26 deletions

View file

@ -121,14 +121,19 @@
= t '.search.no_results_html', :query => content_tag(:span)
%ul
#no-assets-full-message= t '.sidebar.closet.no_data.description'
%script#sharing-html-image-template{:type => 'text/x-jquery-tmpl'}
= link_to image_tag('${image_url}'), '${permalink}'
%script#sharing-html-text-template{:type => 'text/x-jquery-tmpl'}
= link_to t('app_name'), '${permalink}'
%script#sharing-bbcode-image-template{:type => 'text/x-jquery-tmpl'}
[URL=${permalink}][IMG]${image_url}[/IMG][/URL]
%script#sharing-bbcode-text-template{:type => 'text/x-jquery-tmpl'}
[URL=${permalink}]#{t('app_name')}[/URL]
%script#outfit-template{:type => 'text/x-jquery-tmpl'}
<li class="outfit-${id}{{if starred}} starred{{/if}}">
%header
@ -151,6 +156,7 @@
%a.outfit-delete-confirmation-no{:href => '#'}
= t '.sidebar.outfits.outfit.delete_confirmation.cancel'
</li>
%script#item-template{:type => 'text/x-jquery-tmpl'}
%li{:class => 'object object-${id}'}
%img{:src => '${thumbnail_url}', :title => '${description}', :alt => ''}
@ -171,6 +177,27 @@
{{/if}}
{{/if}}
%span.no-assets-message= t '.sidebar.closet.no_data.summary'
%script#pagination-template{:type => 'text/x-jquery-tmpl'}
{{if current_page > 1}}
= link_to t('will_paginate.previous_label').html_safe, '#', :rel => 'prev',
'data-page' => '${current_page - 1}'
{{/if}}
{{each pages}}
{{if $value == 'gap'}}
%span.gap= t('will_paginate.page_gap').html_safe
{{else $value == current_page}}
%em.current ${$value}
{{else}}
= link_to '${$value}', '#', 'data-page' => '${$value}'
{{/if}}
{{/each}}
{{if current_page < total_pages}}
= link_to t('will_paginate.next_label').html_safe, '#', :rel => 'next',
'data-page' => '${current_page + 1}'
{{/if}}
%span#userbar-session-message
- if user_signed_in?

View file

@ -0,0 +1,18 @@
en-meep:
will_paginate:
previous_label: "&#8592; Preevious"
next_label: "Neext &#8594;"
page_gap: "&hellip;!"
page_entries_info:
single_page:
zero: "No %{model} meeped"
one: "Meeping 1 %{model}"
other: "Meeping all %{count} %{model}"
single_page_html:
zero: "No %{model} meeped"
one: "Meeping <b>1</b> %{model}"
other: "Meeping <b>all&nbsp;%{count}</b> %{model}"
multi_page: "Meeping %{model} %{from} - %{to} of %{count} in total"
multi_page_html: "Meeping %{model} <b>%{from}&nbsp;-&nbsp;%{to}</b> of <b>%{count}</b> in total"

View file

@ -1086,19 +1086,12 @@ View.Search = function (wardrobe) {
PAGINATION = {
INNER_WINDOW: 4,
OUTER_WINDOW: 1,
GAP_TEXT: '&hellip;',
PREV_TEXT: '&larr; Previous',
NEXT_TEXT: 'Next &rarr;',
PAGE_EL: $('<a/>', {href: '#'}),
CURRENT_EL: $('<span/>', {'class': 'current'}),
EL_ID: '#preview-search-form-pagination',
PER_PAGE: 21
PER_PAGE: 21,
TEMPLATE: $('#pagination-template')
}, object_width = 112, last_request;
PAGINATION.EL = $(PAGINATION.EL_ID);
PAGINATION.GAP_EL = $('<span/>', {'class': 'gap', html: PAGINATION.GAP_TEXT})
PAGINATION.PREV_EL = $('<a/>', {href: '#', rel: 'prev', html: PAGINATION.PREV_TEXT});
PAGINATION.NEXT_EL = $('<a/>', {href: '#', rel: 'next', html: PAGINATION.NEXT_TEXT});
$(PAGINATION.EL_ID + ' a').live('click', function (e) {
e.preventDefault();
@ -1205,33 +1198,28 @@ View.Search = function (wardrobe) {
subtract_left = (left_gap[1] - left_gap[0]) > 1;
subtract_right = (right_gap[1] - right_gap[0]) > 1;
PAGINATION.EL.children().remove();
if(current_page > 1) {
PAGINATION.PREV_EL.clone().data('page', current_page - 1).appendTo(PAGINATION.EL);
}
var pages = [];
while(i <= total_pages) {
if(subtract_left && i >= left_gap[0] && i < left_gap[1]) {
PAGINATION.GAP_EL.clone().appendTo(PAGINATION.EL);
pages.push('gap');
i = left_gap[1];
} else if(subtract_right && i >= right_gap[0] && i < right_gap[1]) {
PAGINATION.GAP_EL.clone().appendTo(PAGINATION.EL);
pages.push('gap');
i = right_gap[1];
} else {
if(i == current_page) {
PAGINATION.CURRENT_EL.clone().text(i).appendTo(PAGINATION.EL);
} else {
PAGINATION.PAGE_EL.clone().text(i).data('page', i).appendTo(PAGINATION.EL);
}
pages.push(i);
i++;
}
}
if(current_page < total_pages) {
PAGINATION.NEXT_EL.clone().data('page', current_page + 1).appendTo(PAGINATION.EL);
}
PAGINATION.EL.empty();
PAGINATION.TEMPLATE.tmpl({
current_page: current_page,
total_pages: total_pages,
pages: pages
}).appendTo(PAGINATION.EL);
});
wardrobe.search.bind('error', function (error) {