Project

General

Profile

« Previous | Next » 

Revision 514767df

Added by Amir Fefer about 7 years ago

Fixes #19176 - fix translated strings in select all hosts

View differences:

app/assets/javascripts/host_checkbox.js
function multiple_selection() {
var total = $("#pagination").data("count");
var alert_text = Jed.sprintf(__("All <b> %d </b> hosts are selected. "), total);
var alert_text = Jed.sprintf(n__("Single host is selected in total",
"All <b> %d </b> hosts are selected.", total), total);
var undo_text = __("Undo selection");
var multiple_alert = $("#multiple-alert");
multiple_alert.find(".text").html(alert_text + '<a href="#" onclick="undo_multiple_selection();">' + undo_text + '</a>');
multiple_alert.find(".text").html(alert_text + ' <a href="#" onclick="undo_multiple_selection();">' + undo_text + '</a>');
multiple_alert.data('multiple', true)
}
function undo_multiple_selection() {
var pagination = pagination_metadata();
var alert_text = Jed.sprintf(__("All %s hosts on this page are selected. "), pagination.per_page);
var select_text = Jed.sprintf(__("Select all<b> %s </b> hosts"), pagination.total);
var alert_text = Jed.sprintf(n__("Single host on this page is selected.",
"All %s hosts on this page are selected.", pagination.per_page), pagination.per_page);
var select_text = Jed.sprintf(n__("Select this host",
"Select all<b> %s </b> hosts", pagination.total), pagination.total);
var multiple_alert = $("#multiple-alert");
multiple_alert.find(".text").html( alert_text + '<a href="#" onclick="multiple_selection();">' + select_text + '</a>');
multiple_alert.find(".text").html( alert_text + ' <a href="#" onclick="multiple_selection();">' + select_text + '</a>');
multiple_alert.data('multiple', false)
}
app/helpers/hosts_and_hostgroups_helper.rb
def multiple_filter(hosts)
return unless multiple_with_filter?
no_filter = _("Reminder: <strong> All #{hosts.size} hosts are selected </strong>").html_safe
with_filter = _("Reminder: <strong> All #{hosts.size} hosts are selected </strong> for query filter #{h(params[:search])}").html_safe
host_count = hosts.size
no_filter = n_("Reminder: <strong> One host is selected </strong>",
"Reminder: <strong> All %{count} hosts are selected </strong>", host_count).html_safe % {count: host_count}
with_filter = n_("Reminder: <strong> One host is selected </strong> for query filter %{query}",
"Reminder: <strong> All %{count} hosts are selected </strong> for query filter %{query}", host_count).html_safe % {count: host_count, query: h(params[:search]) }
params[:search].blank? ? no_filter : with_filter
end
end
app/views/hosts/index.html.erb
<% title_actions multiple_actions_select, csv_link, button_group(new_link(_("Create Host"))) %>
<%= alert(:class => 'alert-info hide', :id => 'multiple-alert', :close => false, :header => '',
:text => _("All #{per_page(@hosts)} hosts on this page are selected. ").html_safe +
link_to_function((_("Select all <b> #{@hosts.total_entries.to_s} </b> hosts")).html_safe, "multiple_selection()")) %>
:text => n_("Single host on this page is selected.",
"All %{per_page} hosts on this page are selected.", per_page(@hosts)).html_safe % {per_page: per_page(@hosts)} + ' ' +
link_to_function(n_("Select this host",
"Select all <b> %{total} </b> hosts", @hosts.total_entries).html_safe % {total: @hosts.total_entries},
"multiple_selection()")) %>
<%= render 'list', :hosts => @hosts, :header => @title || _("Hosts") %>

Also available in: Unified diff