Client-side translation for the About and Dashboard modules.

pull/3/head
Dave Page 2017-03-22 12:57:59 +00:00
parent 90a369b7de
commit 5b12fd6d5f
2 changed files with 70 additions and 70 deletions

View File

@ -1,6 +1,6 @@
define(
['jquery', 'alertify', 'pgadmin'],
function($, alertify, pgAdmin) {
['jquery', 'alertify', 'pgadmin', 'sources/translate'],
function($, alertify, pgAdmin, t) {
pgAdmin = pgAdmin || window.pgAdmin || {};
/* Return back, this has been called more than once */
@ -18,7 +18,7 @@ define(
},
setup: function() {
return {
buttons:[{ text: "OK", key: 27, className: "btn btn-primary" }],
buttons:[{ text: t("OK"), key: 27, className: "btn btn-primary" }],
options: {
modal: false,
resizable: true,
@ -41,7 +41,7 @@ define(
var content = '';
$.get("{{ url_for('about.index') }}",
function(data) {
alertify.aboutDialog('About {{ config.APP_NAME }}', data).resizeTo(800, 450);
alertify.aboutDialog(t("About %(appname)s", {appname: "{{ config.APP_NAME }}"}), data).resizeTo(800, 450);
});
}
};

View File

@ -1,8 +1,8 @@
define([
'require', 'jquery', 'pgadmin', 'underscore', 'backbone', 'flotr2', 'wcdocker',
'require', 'jquery', 'pgadmin', 'underscore', 'backbone', 'sources/translate', 'flotr2', 'wcdocker',
'pgadmin.browser', 'bootstrap'
],
function(r, $, pgAdmin, _, Backbone) {
function(r, $, pgAdmin, _, Backbone, t) {
var wcDocker = window.wcDocker,
pgBrowser = pgAdmin.Browser;
@ -41,7 +41,7 @@ function(r, $, pgAdmin, _, Backbone) {
},
error: function (xhr, status) {
$(div).html(
'<div class="alert alert-danger pg-panel-message" role="alert">{{ gettext('An error occurred whilst loading the dashboard.') }}</div>'
'<div class="alert alert-danger pg-panel-message" role="alert">' + t('An error occurred whilst loading the dashboard.') + '</div>'
);
}
});
@ -101,7 +101,7 @@ function(r, $, pgAdmin, _, Backbone) {
},
error: function (xhr, status) {
$(div).html(
'<div class="alert alert-danger pg-panel-message" role="alert">{{ gettext('An error occurred whilst loading the dashboard.') }}</div>'
'<div class="alert alert-danger pg-panel-message" role="alert">' + t('An error occurred whilst loading the dashboard.') + '</div>'
);
}
});
@ -209,11 +209,11 @@ function(r, $, pgAdmin, _, Backbone) {
// If we get a 428, it means the server isn't connected
if (xhr.status == 428) {
if (_.isUndefined(msg) || _.isNull(msg)) {
msg = '{{ gettext('Please connect to the selected server to view the graph.') }}';
msg = t('Please connect to the selected server to view the graph.');
}
cls = 'info';
} else {
msg = '{{ gettext('An error occurred whilst rendering the graph.') }}';
msg = t('An error occurred whilst rendering the graph.');
cls = 'danger';
}
@ -331,11 +331,11 @@ function(r, $, pgAdmin, _, Backbone) {
// If we get a 428, it means the server isn't connected
if (xhr.status == 428) {
if (_.isUndefined(msg) || _.isNull(msg)) {
msg = '{{ gettext('Please connect to the selected server to view the table.') }}';
msg = t('Please connect to the selected server to view the table.');
}
cls = 'info';
} else {
msg = '{{ gettext('An error occurred whilst rendering the table.') }}';
msg = t('An error occurred whilst rendering the table.');
cls = 'danger';
}
@ -400,37 +400,37 @@ function(r, $, pgAdmin, _, Backbone) {
var server_activity_columns = [{
name: "pid",
label: "{{ _('PID') }}",
label: t('PID'),
editable: false,
cell: "string"
}, {
name: "datname",
label: "{{ _('Database') }}",
label: t('Database'),
editable: false,
cell: "string"
}, {
name: "usename",
label: "{{ _('User') }}",
label: t('User'),
editable: false,
cell: "string"
}, {
name: "application_name",
label: "{{ _('Application') }}",
label: t('Application'),
editable: false,
cell: "string"
}, {
name: "client_addr",
label: "{{ _('Client') }}",
label: t('Client'),
editable: false,
cell: "string"
}, {
name: "backend_start",
label: "{{ _('Backend start') }}",
label: t('Backend start'),
editable: false,
cell: "string"
}, {
name: "state",
label: "{{ _('State') }}",
label: t('State'),
editable: false,
cell: "string"
}];
@ -439,7 +439,7 @@ function(r, $, pgAdmin, _, Backbone) {
server_activity_columns = server_activity_columns.concat(
[{
name: "waiting",
label: "{{ _('Waiting?') }}",
label: t('Waiting?'),
editable: false,
cell: "string"
}]);
@ -447,12 +447,12 @@ function(r, $, pgAdmin, _, Backbone) {
server_activity_columns = server_activity_columns.concat(
[{
name: "wait_event",
label: "{{ _('Wait Event') }}",
label: t('Wait Event'),
editable: false,
cell: "string"
},{
name: "blocking_pids",
label: "{{ _('Blocking PIDs') }}",
label: t('Blocking PIDs'),
editable: false,
cell: "string"
}]);
@ -460,121 +460,121 @@ function(r, $, pgAdmin, _, Backbone) {
var server_locks_columns = [{
name: "pid",
label: "{{ _('PID') }}",
label: t('PID'),
editable: false,
cell: "string"
}, {
name: "datname",
label: "{{ _('Database') }}",
label: t('Database'),
editable: false,
cell: "string"
}, {
name: "locktype",
label: "{{ _('Lock type') }}",
label: t('Lock type'),
editable: false,
cell: "string"
}, {
name: "relation",
label: "{{ _('Target relation') }}",
label: t('Target relation'),
editable: false,
cell: "string"
}, {
name: "page",
label: "{{ _('Page') }}",
label: t('Page'),
editable: false,
cell: "string"
}, {
name: "tuple",
label: "{{ _('Tuple') }}",
label: t('Tuple'),
editable: false,
cell: "string"
}, {
name: "virtualxid",
label: "{{ _('vXID (target)') }}",
label: t('vXID (target)'),
editable: false,
cell: "string"
}, {
name: "transactionid",
label: "{{ _('XID (target)') }}",
label: t('XID (target)'),
editable: false,
cell: "string"
},{
name: "classid",
label: "{{ _('Class') }}",
label: t('Class'),
editable: false,
cell: "string"
},{
name: "objid",
label: "{{ _('Object ID') }}",
label: t('Object ID'),
editable: false,
cell: "string"
},{
name: "virtualtransaction",
label: "{{ _('vXID (owner)') }}",
label: t('vXID (owner)'),
editable: false,
cell: "string"
},{
name: "mode",
label: "{{ _('Mode') }}",
label: t('Mode'),
editable: false,
cell: "string"
},{
name: "granted",
label: "{{ _('Granted?') }}",
label: t('Granted?'),
editable: false,
cell: "string"
}];
var server_prepared_columns = [{
name: "git",
label: "{{ _('Name') }}",
label: t('Name'),
editable: false,
cell: "string"
}, {
name: "database",
label: "{{ _('Database') }}",
label: t('Database'),
editable: false,
cell: "string"
}, {
name: "Owner",
label: "{{ _('Owner') }}",
label: t('Owner'),
editable: false,
cell: "string"
}, {
name: "transaction",
label: "{{ _('XID') }}",
label: t('XID'),
editable: false,
cell: "string"
}, {
name: "prepared",
label: "{{ _('Prepared at') }}",
label: t('Prepared at'),
editable: false,
cell: "string"
}];
var server_config_columns = [{
name: "name",
label: "{{ _('Name') }}",
label: t('Name'),
editable: false,
cell: "string"
}, {
name: "category",
label: "{{ _('Category') }}",
label: t('Category'),
editable: false,
cell: "string"
}, {
name: "setting",
label: "{{ _('Setting') }}",
label: t('Setting'),
editable: false,
cell: "string"
}, {
name: "unit",
label: "{{ _('Unit') }}",
label: t('Unit'),
editable: false,
cell: "string"
}, {
name: "short_desc",
label: "{{ _('Description') }}",
label: t('Description'),
editable: false,
cell: "string"
}];
@ -677,32 +677,32 @@ function(r, $, pgAdmin, _, Backbone) {
var database_activity_columns = [{
name: "pid",
label: "{{ _('PID') }}",
label: t('PID'),
editable: false,
cell: "string"
}, {
name: "usename",
label: "{{ _('User') }}",
label: t('User'),
editable: false,
cell: "string"
}, {
name: "application_name",
label: "{{ _('Application') }}",
label: t('Application'),
editable: false,
cell: "string"
}, {
name: "client_addr",
label: "{{ _('Client') }}",
label: t('Client'),
editable: false,
cell: "string"
}, {
name: "backend_start",
label: "{{ _('Backend start') }}",
label: t('Backend start'),
editable: false,
cell: "string"
}, {
name: "state",
label: "{{ _('State') }}",
label: t('State'),
editable: false,
cell: "string"
}];
@ -711,7 +711,7 @@ function(r, $, pgAdmin, _, Backbone) {
database_activity_columns = database_activity_columns.concat(
[{
name: "waiting",
label: "{{ _('Waiting?') }}",
label: t('Waiting?'),
editable: false,
cell: "string"
}]);
@ -719,12 +719,12 @@ function(r, $, pgAdmin, _, Backbone) {
database_activity_columns = database_activity_columns.concat(
[{
name: "wait_event",
label: "{{ _('Wait Event') }}",
label: t('Wait Event'),
editable: false,
cell: "string"
},{
name: "blocking_pids",
label: "{{ _('Blocking PIDs') }}",
label: t('Blocking PIDs'),
editable: false,
cell: "string"
}]);
@ -732,84 +732,84 @@ function(r, $, pgAdmin, _, Backbone) {
var database_locks_columns = [{
name: "pid",
label: "{{ _('PID') }}",
label: t('PID'),
editable: false,
cell: "string"
}, {
name: "locktype",
label: "{{ _('Lock type') }}",
label: t('Lock type'),
editable: false,
cell: "string"
}, {
name: "relation",
label: "{{ _('Target relation') }}",
label: t('Target relation'),
editable: false,
cell: "string"
}, {
name: "page",
label: "{{ _('Page') }}",
label: t('Page'),
editable: false,
cell: "string"
}, {
name: "tuple",
label: "{{ _('Tuple') }}",
label: t('Tuple'),
editable: false,
cell: "string"
}, {
name: "virtualxid",
label: "{{ _('vXID (target)') }}",
label: t('vXID (target)'),
editable: false,
cell: "string"
}, {
name: "transactionid",
label: "{{ _('XID (target)') }}",
label: t('XID (target)'),
editable: false,
cell: "string"
},{
name: "classid",
label: "{{ _('Class') }}",
label: t('Class'),
editable: false,
cell: "string"
},{
name: "objid",
label: "{{ _('Object ID') }}",
label: t('Object ID'),
editable: false,
cell: "string"
},{
name: "virtualtransaction",
label: "{{ _('vXID (owner)') }}",
label: t('vXID (owner)'),
editable: false,
cell: "string"
},{
name: "mode",
label: "{{ _('Mode') }}",
label: t('Mode'),
editable: false,
cell: "string"
},{
name: "granted",
label: "{{ _('Granted?') }}",
label: t('Granted?'),
editable: false,
cell: "string"
}];
var database_prepared_columns = [{
name: "git",
label: "{{ _('Name') }}",
label: t('Name'),
editable: false,
cell: "string"
}, {
name: "Owner",
label: "{{ _('Owner') }}",
label: t('Owner'),
editable: false,
cell: "string"
}, {
name: "transaction",
label: "{{ _('XID') }}",
label: t('XID'),
editable: false,
cell: "string"
}, {
name: "prepared",
label: "{{ _('Prepared at') }}",
label: t('Prepared at'),
editable: false,
cell: "string"
}];