Project

General

Profile

« Previous | Next » 

Revision ad01d4d2

Added by Walden Raines over 10 years ago

fixes #3984 - use __ instead of _ for i18n to avoid conflict with underscore.js

View differences:

app/assets/javascripts/about.js
type: 'post',
url: url,
success: function(response) {
item.text(_(response.status));
item.text(__(response.status));
item.attr('title',response.message);
if(response.status == "OK"){
item.addClass('label label-success')
app/assets/javascripts/application.js
if (status == "error") {
$(div).html('<div class="alert alert-warning alert-dismissable">' +
'<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>' +
_('Sorry but no templates were configured.') + '</div>');
__('Sorry but no templates were configured.') + '</div>');
}
});
}
......
var query = encodeURI($("#search").val());
var url = $("#bookmark").attr('data-url');
$("#bookmarks-modal .modal-body").empty();
$("#bookmarks-modal .modal-body").append("<span id='loading'>" + _('Loading ...') + "</span>");
$("#bookmarks-modal .modal-body").append("<span id='loading'>" + __('Loading ...') + "</span>");
$("#bookmarks-modal .modal-body").load(url + '&query=' + query + ' form',
function(response, status, xhr) {
$("#loading").hide();
......
var url = $(this).attr('data-ajax-url');
$(this).load(url, function(response, status, xhr) {
if (status == "error") {
$(this).closest(".tab-content").find("#spinner").html(_('Failed to fetch: ') + xhr.status + " " + xhr.statusText);
$(this).closest(".tab-content").find("#spinner").html(__('Failed to fetch: ') + xhr.status + " " + xhr.statusText);
}
});
});
app/assets/javascripts/charts.js
noColumns:4,
container:"#legendContainer",
labelFormatter: function(label, series) {
return '<a rel="twipsy" data-original-title="' + _('Details') + '" href="' + series.href + '">' + label + '</a>';
return '<a rel="twipsy" data-original-title="' + __('Details') + '" href="' + series.href + '">' + label + '</a>';
}
}
case "hide":
......
yaxis: { min: ranges.yaxis.from, max: ranges.yaxis.to }
}));
if(target.parents('.stats-well').find('.reset-zoom').size() == 0){
target.parents('.stats-well').prepend("<a class='reset-zoom btn btn-sm'>" + _('Reset zoom') + "</a>");
target.parents('.stats-well').prepend("<a class='reset-zoom btn btn-sm'>" + __('Reset zoom') + "</a>");
}
}
......
if($("#"+div).length == 0)
{
$('body').append('<div id="' + div + '" class="modal fade"><div class="modal-dialog"><div class="modal-content"></div></div></div>');
$("#"+div+" .modal-content").append('<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">' + _('Fact Chart') + '</h4></div>')
.append('<div id="' + div + '-body" class="fact_chart modal-body">' + _('Loading') + ' ...</div>')
$("#"+div+" .modal-content").append('<div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button><h4 class="modal-title">' + __('Fact Chart') + '</h4></div>')
.append('<div id="' + div + '-body" class="fact_chart modal-body">' + __('Loading') + ' ...</div>')
.append('<div class="modal-footer"></div>')
$("#"+div).modal('show');
app/assets/javascripts/compute_resource.js
var url = $(this).attr('data-url');
$(this).load(url + ' table', function(response, status, xhr) {
if (status == "error") {
$(this).closest(".tab-content").find("#spinner").html(Jed.sprintf(_("There was an error listing VMs: %(status)s %(statusText)s"), {status: xhr.status, statusText: xhr.statusText}));
$(this).closest(".tab-content").find("#spinner").html(Jed.sprintf(__("There was an error listing VMs: %(status)s %(statusText)s"), {status: xhr.status, statusText: xhr.statusText}));
}
$('.dropdown-toggle').dropdown();
$(document.body).trigger('ContentLoad');
......
allocation.value = capacity.value;
}
return false;
}
}
app/assets/javascripts/config_template.js
function upload_file(evt){
if(window.File && window.FileList && window.FileReader)
{
if (!confirm(_("You are about to override the editor content, are you sure?"))) {
if (!confirm(__("You are about to override the editor content, are you sure?"))) {
$('.template_file').val('');
return;
}
......
var patch = JsDiff.createPatch(item.attr('data-file-name'), $('#old').text(), $('#new').text());
patch = patch.replace(/^(.*\n){0,4}/,'');
if (patch.length == 0)
patch = _("No changes")
patch = __("No changes")
$(session).off('change');
session.setValue(patch);
......
}
function revert_template(item){
if (!confirm(_("You are about to override the editor content with a previous version, are you sure?"))) return;
if (!confirm(__("You are about to override the editor content with a previous version, are you sure?"))) return;
var version = $(item).attr('data-version');
var url = $(item).attr('data-url');
......
set_edit_mode($('.template_text'));
}
var time = $(item).closest('div.row').find('h6 span').attr('data-original-title');
$('#config_template_audit_comment').text(Jed.sprintf(_("Revert to revision from: %s"), time))
$('#config_template_audit_comment').text(Jed.sprintf(__("Revert to revision from: %s"), time))
}
})
}
app/assets/javascripts/host_edit.js
$("#compute_profile").show();
$('#vm_details').empty();
var data = $('form').serialize().replace('method=put', 'method=post');
$('#compute_resource').html(spinner_placeholder(_('Loading virtual machine information ...')));
$('#compute_resource').html(spinner_placeholder(__('Loading virtual machine information ...')));
$('#compute_resource_tab a').removeClass('tab-error');
$(item).indicator_show();
var url = $(item).attr('data-url');
......
data: data,
complete: function(){$(item).indicator_hide()},
error: function(jqXHR, status, error){
$('#compute_resource').html(Jed.sprintf(_("Error loading virtual machine information: %s"), error));
$('#compute_resource').html(Jed.sprintf(__("Error loading virtual machine information: %s"), error));
$('#compute_resource_tab a').addClass('tab-error');
},
success: function(result){
......
var link = content.children('a');
var links = content.find('a');
links.attr('onclick', 'remove_puppet_class(this)');
links.attr('data-original-title', _('Click to undo adding this class'));
links.attr('data-original-title', __('Click to undo adding this class'));
links.tooltip();
link.removeClass('glyphicon-plus-sign').addClass('glyphicon-minus-sign');
......
if (url == undefined) return; // no parameters
var placeholder = $('<tr id="puppetclass_'+id+'_params_loading">'+
'<td colspan="5">' + spinner_placeholder(_('Loading parameters...')) + '</td></tr>');
'<td colspan="5">' + spinner_placeholder(__('Loading parameters...')) + '</td></tr>');
$('#inherited_puppetclasses_parameters').append(placeholder);
$.ajax({
url: url,
......
function load_with_placeholder(target, url, data){
if(url==undefined) return;
var placeholder = $('<tr id="' + target + '_loading" >'+
'<td colspan="4">'+ spinner_placeholder(_('Loading parameters...')) + '</td></tr>');
'<td colspan="4">'+ spinner_placeholder(__('Loading parameters...')) + '</td></tr>');
$('#' + target + ' tbody').replaceWith(placeholder);
$.ajax({
type:'post',
......
subnet_options.attr('disabled', true);
if (domain_id == '') {
subnet_options.append($("<option />").val(null).text(_('No subnets')));
subnet_options.append($("<option />").val(null).text(__('No subnets')));
return false;
}
......
dataType:'json',
success:function (result) {
if (result.length > 1)
subnet_options.append($("<option />").val(null).text(_('Please select')));
subnet_options.append($("<option />").val(null).text(__('Please select')));
$.each(result, function () {
subnet_options.append($("<option />").val(this.subnet.id).text(this.subnet.name + ' (' + this.subnet.to_label + ')'));
......
subnet_options.change();
}
else {
subnet_options.append($("<option />").text(_('No subnets')));
subnet_options.append($("<option />").text(__('No subnets')));
subnet_options.attr('disabled', true);
}
$(element).indicator_hide();
......
$(this).attr("disabled", "disabled");
});
$("a.disable-unsupported").remove();
}
}
app/assets/javascripts/i18n.js
// Add normal gettext aliases with gettext_i18n_rails_js to enable extraction
// when SETTINGS[:mark_translated] is enabled, wrap all strings
if (typeof(I18N_MARK) != 'undefined' && I18N_MARK) {
window._ = function() { return 'X' + i18n.gettext.apply(i18n, arguments) + 'X' };
window.n_ = function() { return 'X' + i18n.ngettext.apply(i18n, arguments) + 'X' };
} else {
window._ = window.__;
window.n_ = window.n__;
window.__ = function() { return 'X' + i18n.gettext.apply(i18n, arguments) + 'X' };
window.n__ = function() { return 'X' + i18n.ngettext.apply(i18n, arguments) + 'X' };
}
});
app/assets/javascripts/lookup_keys.js
var field = '';
if (assoc == 'lookup_keys') {
$('#smart_vars .smart-var-tabs .active, #smart_vars .smart-var-content .active').removeClass('active');
var pill = "<li class='active'><a data-toggle='pill' href='#new_" + new_id + "' id='pill_new_" + new_id + "'>" + _('new') + "<span class='badge close pull-right'>&times;</span></a></li>"
var pill = "<li class='active'><a data-toggle='pill' href='#new_" + new_id + "' id='pill_new_" + new_id + "'>" + __('new') + "<span class='badge close pull-right'>&times;</span></a></li>"
$('#smart_vars .smart-var-tabs').prepend(pill);
field = $('#smart_vars .smart-var-content').prepend($(content).addClass('active'));
$('#smart_vars .smart-var-tabs li.active a').show('highlight', 500);
app/assets/javascripts/reports.js
var source = $('td:contains("---")');
source.contents().wrap("<div class='origin'></div>");
source.prepend("<a href='#' onclick='show_diff(this)' >" + _('View Diff') + "</a>");
source.prepend("<a href='#' onclick='show_diff(this)' >" + __('View Diff') + "</a>");
$('.origin').hide();
});
app/assets/javascripts/settings.js
var common_settings = {
method : 'PUT',
indicator : spinner_placeholder(),
tooltip : _('Click to edit..'),
placeholder : _('Click to edit..'),
tooltip : __('Click to edit..'),
placeholder : __('Click to edit..'),
submitdata : {authenticity_token: AUTH_TOKEN, format : "json"},
onblur : 'nothing',
oneditcomplete : function(){
......
var settings = {
type : 'text',
name : $(this).attr('name'),
submit : _('Save'),
cancel : _('Cancel'),
submit : __('Save'),
cancel : __('Cancel'),
width: '100%',
height: '34px'
};
......
type : 'select',
name : $(this).attr('name'),
data : $(this).attr('select_values'),
submit : _('Save')
submit : __('Save')
};
$(this).editable($(this).attr('data-url'), $.extend(common_settings, settings));
});
......
function onLeaveEdit(item){
item.addClass("editable");
item.tooltip()
}
}
app/assets/javascripts/spice.js
var password = $('#spice-area').data('password');
if ((!host) || (!port)) {
console.log(_("must set host and port"));
console.log(__("must set host and port"));
return;
}
......
}
function spice_success(m) {
$('#spice-status').text(Jed.sprintf(_('Connected (unencrypted) to: %s'), $('#spice-status').attr('data-host')))
$('#spice-status').text(Jed.sprintf(__('Connected (unencrypted) to: %s'), $('#spice-status').attr('data-host')))
$('#spice-status').addClass('label-success');
}
app/assets/javascripts/two-pane.js
if ($('.two-pane-left').length == 0){
$('.table-two-pane').wrap( "<div class='row'><div class='col-md-3 two-pane-left'></div></div>");
}
var placeholder = spinner_placeholder(_('Loading'));
var placeholder = spinner_placeholder(__('Loading'));
$('.two-pane-left').after("<div class='col-md-9 two-pane-right'><div class='well'>" + placeholder + "</div></div>");
}
lib/tasks/locale.rake
FileUtils.rm "#{filename}.tmp"
end
# just revert to the traditional underscore.
GettextI18nRailsJs::JsAndCoffeeParser.js_gettext_function = '_' if defined? GettextI18nRailsJs
desc 'Extract strings from codebase'
task :find_code => ["gettext:find", "gettext:po_to_json"]
vendor/assets/javascripts/jquery.multi-select.js
$('select[multiple]').each(function(i,item){
$(item).multiSelect({
disabledClass : 'disabled disabled_item',
selectableHeader: $("<div class='ms-header'>" + _('All items') + " <input placeholder='" + _('Filter') + "' class='ms-filter' type='text'><a href='#' title='" + _('Select All') + "' class='ms-select-all pull-right glyphicon glyphicon-plus icon-white'></a></div>"),
selectionHeader: $("<div class='ms-header'>" + _('Selected items') + "<a href='#' title='" + _('Deselect All') + "' class='ms-deselect-all pull-right glyphicon glyphicon-minus icon-white'></a></div>")
selectableHeader: $("<div class='ms-header'>" + __('All items') + " <input placeholder='" + __('Filter') + "' class='ms-filter' type='text'><a href='#' title='" + __('Select All') + "' class='ms-select-all pull-right glyphicon glyphicon-plus icon-white'></a></div>"),
selectionHeader: $("<div class='ms-header'>" + __('Selected items') + "<a href='#' title='" + __('Deselect All') + "' class='ms-deselect-all pull-right glyphicon glyphicon-minus icon-white'></a></div>")
})
});
......
var missing_ids = $.parseJSON(mismatches);
$.each(missing_ids, function(index,missing_id){
opt_id = (missing_id +"").replace(/[^A-Za-z0-9]*/gi, '_')+'-selectable';
$('#ms-'+$(item).attr('id')).find('#'+opt_id).addClass('delete').tooltip({title: _("Select this since it belongs to a host"), placement: "left"});
$('#ms-'+$(item).attr('id')).find('#'+opt_id).addClass('delete').tooltip({title: __("Select this since it belongs to a host"), placement: "left"});
})
}
})

Also available in: Unified diff