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:
Ashesh Vashi
2017-06-07 15:53:02 +05:30
parent 7e9f82bc17
commit ae80976689
77 changed files with 2603 additions and 2624 deletions

View File

@@ -1,9 +1,9 @@
define(
['jquery', 'underscore', 'underscore.string', 'alertify', 'pgadmin',
'pgadmin.browser', 'backbone', 'backgrid', 'codemirror', 'backform',
'pgadmin.tools.debugger.ui', 'wcdocker', 'pgadmin.backform',
'pgadmin.backgrid', 'pgadmin.browser.frame'],
function($, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform, get_function_arguments) {
define([
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'alertify',
'pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'codemirror',
'backform', 'pgadmin.tools.debugger.ui', 'wcdocker', 'pgadmin.backform',
'pgadmin.backgrid', 'pgadmin.browser.frame'
], function(gettext, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform, get_function_arguments) {
pgAdmin = pgAdmin || window.pgAdmin || {};
@@ -25,61 +25,61 @@ define(
pgBrowser.add_menus([{
name: 'direct_debugger', node: 'function', module: this,
applies: ['object', 'context'], callback: 'get_function_information',
category: 'Debugging', priority: 10, label: '{{ _('Debug') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
data: {object: 'function'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
},{
name: 'global_debugger', node: 'function', module: this,
applies: ['object', 'context'], callback: 'check_func_debuggable',
category: 'Debugging', priority: 10, label: '{{ _('Set breakpoint') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
data: {object: 'function'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
},{
name: 'procedure_direct_debugger', node: 'procedure', module: this,
applies: ['object', 'context'], callback: 'get_function_information',
category: 'Debugging', priority: 10, label: '{{ _('Debug') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
data: {object: 'procedure'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
}, {
name: 'procedure_indirect_debugger', node: 'procedure', module: this,
applies: ['object', 'context'], callback: 'check_func_debuggable',
category: 'Debugging', priority: 10, label: '{{ _('Set breakpoint') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
data: {object: 'procedure'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
}, {
name: 'trigger_function_indirect_debugger', node: 'trigger_function', module: this,
applies: ['object', 'context'], callback: 'check_func_debuggable',
priority: 10, label: '{{ _('Set breakpoint') }}', category: 'Debugging',
priority: 10, label: gettext('Set breakpoint'), category: gettext('Debugging'),
icon: 'fa fa-arrow-circle-right', data: {object:'trigger_function'},
enable: 'can_debug'
}, {
name: 'trigger_indirect_debugger', node: 'trigger', module: this,
applies: ['object', 'context'], callback: 'check_func_debuggable',
priority: 10, label: '{{ _('Set breakpoint') }}', category: 'Debugging',
priority: 10, label: gettext('Set breakpoint'), category: gettext('Debugging'),
icon: 'fa fa-arrow-circle-right', data: {object:'trigger'},
enable: 'can_debug'
}, {
name: 'package_function_direct_debugger', node: 'edbfunc', module: this,
applies: ['object', 'context'], callback: 'get_function_information',
category: 'Debugging', priority: 10, label: '{{ _('Debug') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
data: {object: 'edbfunc'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
},{
name: 'package_function_global_debugger', node: 'edbfunc', module: this,
applies: ['object', 'context'], callback: 'check_func_debuggable',
category: 'Debugging', priority: 10, label: '{{ _('Set breakpoint') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
data: {object: 'edbfunc'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
},{
name: 'package_procedure_direct_debugger', node: 'edbproc', module: this,
applies: ['object', 'context'], callback: 'get_function_information',
category: 'Debugging', priority: 10, label: '{{ _('Debug') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Debug'),
data: {object: 'edbproc'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
}, {
name: 'package_procedure_global_debugger', node: 'edbproc', module: this,
applies: ['object', 'context'], callback: 'check_func_debuggable',
category: 'Debugging', priority: 10, label: '{{ _('Set breakpoint') }}',
category: gettext('Debugging'), priority: 10, label: gettext('Set breakpoint'),
data: {object: 'edbproc'}, icon: 'fa fa-arrow-circle-right',
enable: 'can_debug'
}]);
@@ -87,7 +87,7 @@ define(
// Create and load the new frame required for debugger panel
this.frame = new pgBrowser.Frame({
name: 'frm_debugger',
title: '{{ _('Debugger') }}',
title: gettext('Debugger'),
width: 500,
isCloseable: true,
isPrivate: true,
@@ -306,9 +306,9 @@ define(
get_function_arguments(res.data[0], 0);
}
else {
// Initialize the target and create asynchronous connection and unique transaction ID
// If there is no arguments to the functions then we should not ask for for function arguments and
// Directly open the panel
// Initialize the target and create asynchronous connection and unique transaction ID
// If there is no arguments to the functions then we should not ask for for function arguments and
// Directly open the panel
var t = pgBrowser.tree,
i = t.selected(),
d = i && i.length == 1 ? t.itemData(i) : undefined,

View File

@@ -1,9 +1,9 @@
define(
['jquery', 'underscore', 'underscore.string', 'alertify', 'pgadmin',
'pgadmin.browser', 'backbone', 'backgrid', 'codemirror', 'backform',
'wcdocker', 'pgadmin.backform', 'pgadmin.backgrid',
'pgadmin.browser.panel'],
function($, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform ) {
define([
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'alertify',
'pgadmin', 'pgadmin.browser', 'backbone', 'backgrid', 'codemirror',
'backform', 'wcdocker', 'pgadmin.backform', 'pgadmin.backgrid',
'pgadmin.browser.panel'
], function(gettext, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform ) {
/*
* Function used to return the respective Backgrid control based on the data type
@@ -86,7 +86,7 @@ define(
if (_.isUndefined(this.get('value')) ||
_.isNull(this.get('value')) ||
String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') {
var msg = '{{ _('Please enter a value for the parameter.') }}';
var msg = gettext('Please enter a value for the parameter.');
this.errorModel.set('value', msg);
return msg;
} else {

View File

@@ -1,9 +1,14 @@
define(
['jquery', 'underscore', 'underscore.string', 'alertify', 'pgadmin','pgadmin.browser',
'backbone', 'backgrid', 'codemirror', 'backform','pgadmin.tools.debugger.ui',
'wcdocker', 'pgadmin.backform', 'pgadmin.backgrid', 'codemirror/addon/selection/active-line',
'codemirror/addon/fold/foldgutter', 'codemirror/addon/fold/foldcode', 'pgadmin-sqlfoldcode'],
function($, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid, CodeMirror, Backform, debug_function_again) {
define([
'sources/gettext', 'jquery', 'underscore', 'underscore.string', 'alertify',
'pgadmin','pgadmin.browser', 'backbone', 'backgrid', 'codemirror', 'backform',
'pgadmin.tools.debugger.ui', 'wcdocker', 'pgadmin.backform',
'pgadmin.backgrid', 'codemirror/addon/selection/active-line',
'codemirror/addon/fold/foldgutter', 'codemirror/addon/fold/foldcode',
'pgadmin-sqlfoldcode'
], function(
gettext, $, _, S, Alertify, pgAdmin, pgBrowser, Backbone, Backgrid,
CodeMirror, Backform, debug_function_again
) {
if (pgAdmin.Browser.tree != null) {
pgAdmin = pgAdmin || window.pgAdmin || {};
@@ -360,7 +365,7 @@ define(
pgTools.DirectDebug.polling_timeout_idle = true;
// If status is Busy then poll the result by recursive call to the poll function
if (!pgTools.DirectDebug.debug_type) {
pgTools.DirectDebug.docker.startLoading('{{ _('Waiting for another session to invoke the target...') }}');
pgTools.DirectDebug.docker.startLoading(gettext('Waiting for another session to invoke the target...'));
// As we are waiting for another session to invoke the target,disable all the buttons
self.enable('stop', false);
@@ -1507,7 +1512,7 @@ define(
// Create the parameters panel to display the arguments of the functions
var parameters = new pgAdmin.Browser.Panel({
name: 'parameters',
title: '{{ _('Parameters') }}',
title: gettext('Parameters'),
width: '100%',
height:'100%',
isCloseable: false,
@@ -1518,7 +1523,7 @@ define(
// Create the Local variables panel to display the local variables of the function.
var local_variables = new pgAdmin.Browser.Panel({
name: 'local_variables',
title: '{{ _('Local variables') }}',
title: gettext('Local variables'),
width: '100%',
height:'100%',
isCloseable: false,
@@ -1529,7 +1534,7 @@ define(
// Create the messages panel to display the message returned from the database server
var messages = new pgAdmin.Browser.Panel({
name: 'messages',
title: '{{ _('Messages') }}',
title: gettext('Messages'),
width: '100%',
height:'100%',
isCloseable: false,
@@ -1540,7 +1545,7 @@ define(
// Create the result panel to display the result after debugging the function
var results = new pgAdmin.Browser.Panel({
name: 'results',
title: '{{ _('Results') }}',
title: gettext('Results'),
width: '100%',
height:'100%',
isCloseable: false,
@@ -1551,7 +1556,7 @@ define(
// Create the stack pane panel to display the debugging stack information.
var stack_pane = new pgAdmin.Browser.Panel({
name: 'stack_pane',
title: '{{ _('Stack') }}',
title: gettext('Stack'),
width: '100%',
height:'100%',
isCloseable: false,
@@ -1611,7 +1616,7 @@ define(
self.editor.on("gutterClick", self.onBreakPoint.bind(self), self);
};
self.docker.startLoading('{{ _('Loading...') }}');
self.docker.startLoading(gettext('Loading...'));
self.docker.on(wcDocker.EVENT.LOADED, onLoad);
// Create the toolbar view for debugging the function