mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-09-03 20:52:57 -05:00
Using the client-side translation using the client-side 'gettext'
implementation. This is the first step towards 'Avoid creating the javascript modules using Jinja templates'.
This commit is contained in:
@@ -46,16 +46,7 @@ class BGProcessModule(PgAdminModule):
|
||||
dict: the i18n messages used by this module
|
||||
"""
|
||||
return {
|
||||
'bgprocess.index': url_for("bgprocess.index"),
|
||||
'seconds': _('seconds'),
|
||||
'started': _('Started'),
|
||||
'START_TIME': _('Start time'),
|
||||
'STATUS': _('Status'),
|
||||
'EXECUTION_TIME': _('Execution time'),
|
||||
'running': _('Running...'),
|
||||
'successfully_finished': _("Successfully completed."),
|
||||
'failed_with_exit_code': _("Failed (exit code: %s)."),
|
||||
'BG_TOO_MANY_LOGS': _("Too many logs generated!")
|
||||
'bgprocess.index': url_for("bgprocess.index")
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'pgadmin', 'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
|
||||
'pgadmin', 'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
|
||||
'alertify', 'pgadmin.browser.messages'
|
||||
], function(pgAdmin, _, S, $, pgBrowser, alertify, pgMessages) {
|
||||
], function(pgAdmin, gettext, _, S, $, pgBrowser, alertify, pgMessages) {
|
||||
|
||||
pgBrowser.BackgroundProcessObsorver = pgBrowser.BackgroundProcessObsorver || {};
|
||||
|
||||
@@ -155,18 +155,18 @@ define([
|
||||
}
|
||||
|
||||
if (self.stime) {
|
||||
self.curr_status = pgMessages['started'];
|
||||
self.curr_status = gettext('Started');
|
||||
|
||||
if (self.execution_time >= 2) {
|
||||
self.curr_status = pgMessages['running'];
|
||||
self.curr_status = gettext['Running...'];
|
||||
}
|
||||
|
||||
if (!_.isNull(self.exit_code)) {
|
||||
if (self.exit_code == 0) {
|
||||
self.curr_status = pgMessages['successfully_finished'];
|
||||
self.curr_status = gettext('Successfully completed.');
|
||||
} else {
|
||||
self.curr_status = S(
|
||||
pgMessages['failed_with_exit_code']
|
||||
gettext("Failed (exit code: %s).")
|
||||
).sprintf(String(self.exit_code)).value();
|
||||
}
|
||||
}
|
||||
@@ -240,7 +240,7 @@ define([
|
||||
for_details = $('<div></div>', {
|
||||
class: "col-xs-12 text-center pg-bg-click h6"
|
||||
}).append(
|
||||
$('<span></span>').text(pgMessages.CLICK_FOR_DETAILED_MSG)
|
||||
$('<span></span>').text(gettext('Click here for details.'))
|
||||
).appendTo(content),
|
||||
status = $('<div></div>', {
|
||||
class: "pg-bg-status col-xs-12 h5 " + ((self.exit_code === 0) ?
|
||||
@@ -290,7 +290,7 @@ define([
|
||||
String(self.execution_time)
|
||||
)
|
||||
).append(
|
||||
$('<span></span>').text(' ' + pgMessages['seconds'])
|
||||
$('<span></span>').text(' ' + gettext('seconds'))
|
||||
);
|
||||
self.container.find('.pg-bg-status').empty().append(
|
||||
self.curr_status
|
||||
@@ -348,7 +348,7 @@ define([
|
||||
String(self.execution_time)
|
||||
)
|
||||
).append(
|
||||
$('<span></span>').text(' ' + pgMessages['seconds'])
|
||||
$('<span></span>').text(' ' + gettext('seconds'))
|
||||
);
|
||||
|
||||
if (is_new) {
|
||||
@@ -499,7 +499,7 @@ define([
|
||||
content: '<div class="bg-process-details col-xs-12">'+
|
||||
'<p class="bg-detailed-desc"></p>'+
|
||||
'<div class="bg-process-stats">'+
|
||||
'<span><b>' + pgMessages['START_TIME'] + ': </b>'+
|
||||
'<span><b>' + gettext('Start time') + ': </b>'+
|
||||
'<span class="bgprocess-start-time"></span>'+
|
||||
'</span></div>'+
|
||||
'</div>'+
|
||||
@@ -507,11 +507,11 @@ define([
|
||||
'</div>'+
|
||||
'<div class="bg-process-footer col-xs-12">'+
|
||||
'<div class="bg-process-status col-xs-6">'+
|
||||
'<span><b>' + pgMessages['STATUS'] + ':</b></span><p></p>'+
|
||||
'<span><b>' + gettext('Status') + ':</b></span><p></p>'+
|
||||
'</div>'+
|
||||
'<div class="bg-process-exec-time col-xs-6">'+
|
||||
'<div class="exec-div pull-right">'+
|
||||
'<span><b>' + pgMessages['EXECUTION_TIME'] + ':</b></span><p></p>'+
|
||||
'<span><b>' + gettext('Execution time') + ':</b></span><p></p>'+
|
||||
'</div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
|
||||
'alertify', 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
|
||||
], function(_, S, $, pgBrowser, Alertify) {
|
||||
'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
|
||||
'alertify', 'pgadmin.alertifyjs'
|
||||
], function(gettext, _, S, $, pgBrowser, Alertify) {
|
||||
|
||||
if (pgBrowser.ShowNodeDepends)
|
||||
return pgBrowser.ShowNodeDepends;
|
||||
@@ -241,7 +241,7 @@ define([
|
||||
var timer = setTimeout(function(){
|
||||
// notify user if request is taking longer than 1 second
|
||||
|
||||
$msgContainer.text(pgBrowser.messages['LOADING_MESSAGE']);
|
||||
$msgContainer.text(gettext("Retrieving data from the server..."));
|
||||
$msgContainer.removeClass('hidden');
|
||||
if ($gridContainer) {
|
||||
$gridContainer.addClass('hidden');
|
||||
@@ -272,7 +272,7 @@ define([
|
||||
Alertify.pgNotifier(
|
||||
error, xhr,
|
||||
S(
|
||||
pgBrowser.messages['ERR_RETRIEVAL_INFO']
|
||||
gettext("Error retrieving the information - %s")
|
||||
).sprintf(message || _label).value(),
|
||||
function() {
|
||||
console.log(arguments);
|
||||
@@ -280,7 +280,7 @@ define([
|
||||
);
|
||||
}
|
||||
// show failed message.
|
||||
$msgContainer.text(pgBrowser.messages['LOADING_FAILED']);
|
||||
$msgContainer.text(gettext("Failed to retrieve data from the server."));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
// This defines File Manager dialog
|
||||
define([
|
||||
'jquery', 'underscore', 'alertify'],
|
||||
|
||||
// This defines File Manager dialog
|
||||
function($, _, alertify) {
|
||||
'sources/gettext', 'jquery', 'underscore', 'alertify'
|
||||
], function(gettext, $, _, alertify) {
|
||||
pgAdmin = pgAdmin || window.pgAdmin || {};
|
||||
|
||||
/*
|
||||
@@ -133,10 +132,10 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: "{{ _('Select') }}", className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Select"), className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: "{{ _('Cancel') }}", className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
text: gettext("Cancel"), className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
}
|
||||
],
|
||||
focus: { element: 0 },
|
||||
@@ -147,7 +146,7 @@ define([
|
||||
};
|
||||
},
|
||||
callback: function(closeEvent) {
|
||||
if (closeEvent.button.text == "{{ _('Select') }}") {
|
||||
if (closeEvent.button.text == gettext("Select")) {
|
||||
var newFile = $('.storage_dialog #uploader .input-path').val(),
|
||||
file_data = {'path': $('.currentpath').val()};
|
||||
|
||||
@@ -158,7 +157,7 @@ define([
|
||||
$(innerbody).find('*').off();
|
||||
innerbody.remove();
|
||||
removeTransId(trans_id);
|
||||
} else if (closeEvent.button.text == "{{ _('Cancel') }}") {
|
||||
} else if (closeEvent.button.text == gettext("Cancel")) {
|
||||
var innerbody = $(this.elements.body).find('.storage_content')
|
||||
$(innerbody).find('*').off();
|
||||
innerbody.remove();
|
||||
@@ -255,10 +254,10 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: "{{ _('Select') }}", className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Select"), className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: "{{ _('Cancel') }}", key: 27, className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
}
|
||||
],
|
||||
focus: { element: 0 },
|
||||
@@ -271,7 +270,7 @@ define([
|
||||
};
|
||||
},
|
||||
callback: function(closeEvent) {
|
||||
if (closeEvent.button.text == "{{ _('Select') }}") {
|
||||
if (closeEvent.button.text == gettext("Select")) {
|
||||
var newFile = $('.storage_dialog #uploader .input-path').val(),
|
||||
file_data = {'path': $('.currentpath').val()};
|
||||
|
||||
@@ -283,7 +282,7 @@ define([
|
||||
// Ajax call to store the last directory visited once user press select button
|
||||
|
||||
set_last_traversed_dir(file_data, trans_id);
|
||||
} else if (closeEvent.button.text == "{{ _('Cancel') }}") {
|
||||
} else if (closeEvent.button.text == gettext("Cancel")) {
|
||||
var innerbody = $(this.elements.body).find('.storage_content')
|
||||
$(innerbody).find('*').off();
|
||||
innerbody.remove();
|
||||
@@ -380,10 +379,10 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: "{{ _('Select') }}", className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Select"), className: "btn btn-primary fa fa-file file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: "{{ _('Cancel') }}", key: 27, className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-times pg-alertify-button"
|
||||
}
|
||||
],
|
||||
focus: { element: 0 },
|
||||
@@ -396,7 +395,7 @@ define([
|
||||
};
|
||||
},
|
||||
callback: function(closeEvent) {
|
||||
if (closeEvent.button.text == "{{ _('Select') }}") {
|
||||
if (closeEvent.button.text == gettext("Select")) {
|
||||
var newFile = $('.storage_dialog #uploader .input-path').val(),
|
||||
file_data = {'path': $('.currentpath').val()};
|
||||
pgAdmin.Browser.Events.trigger('pgadmin-storage:finish_btn:select_folder', newFile);
|
||||
@@ -406,7 +405,7 @@ define([
|
||||
removeTransId(trans_id);
|
||||
// Ajax call to store the last directory visited once user press select button
|
||||
set_last_traversed_dir(file_data, trans_id);
|
||||
} else if (closeEvent.button.text == "{{ _('Cancel') }}") {
|
||||
} else if (closeEvent.button.text == gettext("Cancel")) {
|
||||
var innerbody = $(this.elements.body).find('.storage_content')
|
||||
$(innerbody).find('*').off();
|
||||
innerbody.remove();
|
||||
@@ -503,10 +502,10 @@ define([
|
||||
return {
|
||||
buttons:[
|
||||
{
|
||||
text: "{{ _('Create') }}", className: "btn btn-primary fa fa-file file_manager_create file_manager_ok pg-alertify-button disabled"
|
||||
text: gettext("Create"), className: "btn btn-primary fa fa-file file_manager_create file_manager_ok pg-alertify-button disabled"
|
||||
},
|
||||
{
|
||||
text: "{{ _('Cancel') }}", key: 27, className: "btn btn-danger fa fa-times file_manager_create_cancel pg-alertify-button"
|
||||
text: gettext("Cancel"), key: 27, className: "btn btn-danger fa fa-times file_manager_create_cancel pg-alertify-button"
|
||||
}
|
||||
],
|
||||
focus: { element: 0 },
|
||||
@@ -601,13 +600,13 @@ define([
|
||||
},
|
||||
error: function() {
|
||||
$('.file_manager_ok').addClass('disabled');
|
||||
alertify.error('{{ _('Error occurred while checking access permission.') }}');
|
||||
alertify.error( gettext('Error occurred while checking access permission.'));
|
||||
}
|
||||
});
|
||||
return permission;
|
||||
},
|
||||
callback: function(closeEvent) {
|
||||
if (closeEvent.button.text == "{{ _('Create') }}") {
|
||||
if (closeEvent.button.text == gettext("Create")) {
|
||||
var newFile = $('.storage_dialog #uploader .input-path').val(),
|
||||
file_data = {'path': $('.currentpath').val()};
|
||||
|
||||
@@ -628,7 +627,7 @@ define([
|
||||
}
|
||||
|
||||
set_last_traversed_dir(file_data, trans_id);
|
||||
} else if (closeEvent.button.text == "{{ _('Cancel') }}") {
|
||||
} else if (closeEvent.button.text == gettext("Cancel")) {
|
||||
var innerbody = $(this.elements.body).find('.storage_content')
|
||||
$(innerbody).find('*').off();
|
||||
innerbody.remove();
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
// use alertify and underscore js
|
||||
var alertify = require("alertify"),
|
||||
_ = require("underscore"),
|
||||
S = require("underscore.string");
|
||||
S = require("underscore.string")
|
||||
gettext = require("sources/gettext");
|
||||
|
||||
/*---------------------------------------------------------
|
||||
Define functions used for various operations
|
||||
@@ -632,7 +633,7 @@ var checkPermission = function(path) {
|
||||
},
|
||||
error: function() {
|
||||
$('.file_manager_ok').addClass('disabled');
|
||||
alertify.error('{{ _('Error occurred while checking access permission.') }}');
|
||||
alertify.error( gettext('Error occurred while checking access permission.'));
|
||||
}
|
||||
});
|
||||
return permission;
|
||||
@@ -1276,16 +1277,16 @@ if (
|
||||
have_all_types = (have_all_types || (t == '*'));
|
||||
} else {
|
||||
select_box += '<option value="' + t +'">' +
|
||||
(t == '*' ? '{{ _("All Files") }}' : t) + "</option>";
|
||||
(t == '*' ? gettext('All Files') : t) + "</option>";
|
||||
have_all_types = (have_all_types || (t == '*'));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (!have_all_types) {
|
||||
select_box += '<option value="*">{{ _("All Files") }}</option>';
|
||||
select_box += '<option value="*">' + gettext('All Files') + '</option>';
|
||||
}
|
||||
select_box += "</select><label>{{ _('Format') }}: </label></div>";
|
||||
select_box += "</select><label>' + gettext('Format') + ': </label></div>";
|
||||
}
|
||||
|
||||
$(".allowed_file_types").html(select_box);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
|
||||
'alertify', 'pgadmin.alertifyjs', 'pgadmin.browser.messages',
|
||||
], function(_, S, $, pgBrowser, Alertify) {
|
||||
'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'pgadmin.browser',
|
||||
'alertify', 'pgadmin.alertifyjs'
|
||||
], function(gettext, _, S, $, pgBrowser, Alertify) {
|
||||
|
||||
pgBrowser.ShowNodeSQL = pgBrowser.ShowNodeSQL || {};
|
||||
|
||||
@@ -68,7 +68,7 @@ define([
|
||||
function() {
|
||||
var sql = '';
|
||||
if (node) {
|
||||
sql = '-- ' + pgBrowser.messages.NODE_HAS_NO_SQL;
|
||||
sql = '-- ' + gettext("No SQL could be generated for the selected object.");
|
||||
var self = this,
|
||||
n_type = data._type,
|
||||
n_value = -1,
|
||||
@@ -95,7 +95,9 @@ define([
|
||||
timer = setTimeout(function(){
|
||||
// notify user if request is taking longer than 1 second
|
||||
|
||||
pgAdmin.Browser.editor.setValue(pgBrowser.messages['LOADING_MESSAGE']);
|
||||
pgAdmin.Browser.editor.setValue(
|
||||
gettext("Retrieving data from the server...")
|
||||
);
|
||||
}, 1000);
|
||||
},
|
||||
success: function(res) {
|
||||
@@ -116,9 +118,9 @@ define([
|
||||
) {
|
||||
Alertify.pgNotifier(
|
||||
error, xhr,
|
||||
S(
|
||||
pgBrowser.messages['ERR_RETRIEVAL_INFO']
|
||||
).sprintf(message || _label).value(),
|
||||
S(gettext("Error retrieving the information - %s")).sprintf(
|
||||
message || _label
|
||||
).value(),
|
||||
function() {
|
||||
console.log(arguments);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
define([
|
||||
'underscore', 'underscore.string', 'jquery', 'pgadmin.browser', 'backgrid',
|
||||
'sources/gettext', 'underscore', 'underscore.string', 'jquery', 'pgadmin.browser', 'backgrid',
|
||||
'alertify', 'sources/size_prettify'
|
||||
], function(_, S, $, pgBrowser, Backgrid, Alertify, sizePrettify) {
|
||||
], function(gettext, _, S, $, pgBrowser, Backgrid, Alertify, sizePrettify) {
|
||||
|
||||
if (pgBrowser.NodeStatistics)
|
||||
return pgBrowser.NodeStatistics;
|
||||
@@ -78,8 +78,8 @@ define([
|
||||
|
||||
_.extend(
|
||||
PGBooleanCell.prototype.defaults.options, {
|
||||
onText: pgBrowser.messages.TRUE,
|
||||
offText: pgBrowser.messages.FALSE,
|
||||
onText: gettext('True'),
|
||||
offText: gettext('False'),
|
||||
onColor: 'success',
|
||||
offColor: 'primary',
|
||||
size: 'mini'
|
||||
@@ -104,14 +104,14 @@ define([
|
||||
statistic_columns: [{
|
||||
editable: false,
|
||||
name: 'statistics',
|
||||
label: pgBrowser.messages.STATISTICS_LABEL,
|
||||
label: gettext("Statistics"),
|
||||
cell: 'string',
|
||||
headerCell: Backgrid.Extension.CustomHeaderCell,
|
||||
cellHeaderClasses: 'width_percent_25'
|
||||
},{
|
||||
editable: false,
|
||||
name: 'value',
|
||||
label: pgBrowser.messages.STATISTICS_VALUE_LABEL,
|
||||
label: gettext("Value"),
|
||||
cell: 'string'
|
||||
}],
|
||||
panel: pgBrowser.docker.findPanels('statistics'),
|
||||
@@ -180,7 +180,7 @@ define([
|
||||
n_type = node_type;
|
||||
|
||||
if (node) {
|
||||
msg = pgBrowser.messages.NODE_HAS_NO_STATISTICS;
|
||||
msg = gettext("No statistics are available for the selected object.");
|
||||
/* We fetch the statistics only for those node who set the parameter
|
||||
* showStatistics function.
|
||||
*/
|
||||
@@ -209,7 +209,7 @@ define([
|
||||
timer = setTimeout(function(){
|
||||
// notify user if request is taking longer than 1 second
|
||||
|
||||
$msgContainer.text(pgBrowser.messages['LOADING_MESSAGE']);
|
||||
$msgContainer.text(gettext("Retrieving data from the server..."));
|
||||
$msgContainer.removeClass('hidden');
|
||||
if (self.grid) {
|
||||
self.grid.remove();
|
||||
@@ -267,16 +267,16 @@ define([
|
||||
) {
|
||||
Alertify.pgNotifier(
|
||||
error, xhr,
|
||||
S(
|
||||
pgBrowser.messages['ERR_RETRIEVAL_INFO']
|
||||
).sprintf(message || _label).value(),
|
||||
S(gettext("Error retrieving the information - %s")).sprintf(
|
||||
message || _label
|
||||
).value(),
|
||||
function() {
|
||||
console.log(arguments);
|
||||
}
|
||||
);
|
||||
}
|
||||
// show failed message.
|
||||
$msgContainer.text(pgBrowser.messages['LOADING_FAILED']);
|
||||
$msgContainer.text(gettext("Failed to retrieve data from the server."));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user