Added and fixed gettext usage for better translation coverage. Fixes #5284

1) Fixed usage gettext('') instead of _('') in javascript files.
  2) Fixed usage gettext('') instead of `${gettext('')}` in javascript files,
     because "pybabel extract" not support extracting from this syntax.
This commit is contained in:
Libor M 2020-03-24 11:14:05 +05:30 committed by Akshay Joshi
parent 6988ce96d7
commit 94864104e4
45 changed files with 137 additions and 130 deletions

View File

@ -15,6 +15,7 @@ Housekeeping
************
| `Issue #5271 <https://redmine.postgresql.org/issues/5271>`_ - Enhance the color of switch control for both light and dark theme.
| `Issue #5284 <https://redmine.postgresql.org/issues/5284>`_ - Added and fixed gettext usage for better translation coverage.
Bug fixes
*********

View File

@ -1266,13 +1266,14 @@ class ServerNode(PGChildNodeView):
data={
'status': 1,
'result': gettext(
'Named restore point created: {0}'.format(
restore_point_name))
'Named restore point created: {0}').format(
restore_point_name)
})
except Exception as e:
current_app.logger.error(
'Named restore point creation failed ({0})'.format(str(e))
current_app.logger.error(gettext(
'Named restore point creation failed ({0})').format(
str(e))
)
return internal_server_error(errormsg=str(e))

View File

@ -50,7 +50,7 @@ class CastModule(CollectionNodeModule):
"""
NODE_TYPE = 'cast'
COLLECTION_LABEL = 'Casts'
COLLECTION_LABEL = gettext('Casts')
def __init__(self, *args, **kwargs):
super(CastModule, self).__init__(*args, **kwargs)

View File

@ -111,10 +111,10 @@ define('pgadmin.node.event_trigger', [
id: 'enabled', label: gettext('Trigger enabled?'),
group: gettext('Definition'), mode: ['properties', 'edit','create'],
options: [
{label: 'Enable', value: 'O'},
{label: 'Disable', value: 'D'},
{label: 'Replica', value: 'R'},
{label: 'Always', value: 'A'},
{label: gettext('Enable'), value: 'O'},
{label: gettext('Disable'), value: 'D'},
{label: gettext('Replica'), value: 'R'},
{label: gettext('Always'), value: 'A'},
],
control: 'select2', select2: { allowClear: false, width: '100%' },
},{
@ -125,9 +125,9 @@ define('pgadmin.node.event_trigger', [
id: 'eventname', label: gettext('Event'),
group: gettext('Definition'), cell: 'string',
options: [
{label: 'DDL COMMAND START', value: 'DDL_COMMAND_START'},
{label: 'DDL COMMAND END', value: 'DDL_COMMAND_END'},
{label: 'SQL DROP', value: 'SQL_DROP'},
{label: gettext('DDL COMMAND START'), value: 'DDL_COMMAND_START'},
{label: gettext('DDL COMMAND END'), value: 'DDL_COMMAND_END'},
{label: gettext('SQL DROP'), value: 'SQL_DROP'},
],
control: 'select2', select2: { allowClear: false, width: '100%' },
},{

View File

@ -52,8 +52,8 @@ class Properties:
execute_on_text = self.translate_execute_on_text(execute_on)
response = dict(
name=table_information_result['name'],
type=gettext('readable' if not table_information_result[
'writable'] else 'writable'),
type=gettext('readable') if not table_information_result[
'writable'] else gettext('writable'),
format_type=table_information_result['pg_encoding_to_char'],
format_options=table_information_result['fmtopts'],
external_options=table_information_result['options'],
@ -65,14 +65,14 @@ class Properties:
@staticmethod
def translate_execute_on_text(execute_on):
if execute_on['type'] == 'host':
return 'host %s' % execute_on['value']
return gettext('host %s') % execute_on['value']
elif execute_on['type'] == 'per_host':
return 'per host'
return gettext('per host')
elif execute_on['type'] == 'master_only':
return 'master segment'
return gettext('master segment')
elif execute_on['type'] == 'all_segments':
return 'all segments'
return gettext('all segments')
elif execute_on['type'] == 'segment':
return '%s segment' % execute_on['value']
return gettext('%s segment') % execute_on['value']
elif execute_on['type'] == 'segments':
return '%d segments' % execute_on['value']
return gettext('%d segments') % execute_on['value']

View File

@ -450,7 +450,7 @@ define('pgadmin.node.exclusion_constraint', [
titleTmpl = _.template([
'<div class="subnode-header">',
' <label class="control-label pg-el-sm-10"><%-label%></label>',
' <button class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="' + _('Add new row') + '"></button>',
' <button class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="' + gettext('Add new row') + '"></button>',
'</div>'].join('\n')),
$gridBody =
$('<div class=\'pgadmin-control-group backgrid form-group col-12 object subnode\'></div>').append(

View File

@ -378,7 +378,7 @@ define('pgadmin.node.foreign_key', [
titleTmpl = _.template([
'<div class="subnode-header">',
' <label class="control-label pg-el-sm-10"><%-label%></label>',
' <button class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="' + _('Add new row') + '"></button>',
' <button class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="' + gettext('Add new row') + '"></button>',
'</div>'].join('\n')),
$gridBody =
$('<div class=\'pgadmin-control-group backgrid form-group col-12 object subnode\'></div>').append(

View File

@ -71,12 +71,12 @@ function(
// To enable/disable all triggers for the table
name: 'enable_all_triggers', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'enable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Enable All'),
category: gettext('Trigger(s)'), priority: 4, label: gettext('Enable All'),
icon: 'fa fa-check', enable : 'canCreate_with_trigger_enable',
},{
name: 'disable_all_triggers', node: 'partition', module: this,
applies: ['object', 'context'], callback: 'disable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Disable All'),
category: gettext('Trigger(s)'), priority: 4, label: gettext('Disable All'),
icon: 'fa fa-times', enable : 'canCreate_with_trigger_disable',
},{
name: 'reset_table_stats', node: 'partition', module: this,

View File

@ -82,23 +82,23 @@ define('pgadmin.node.table', [
},{
name: 'truncate_table', node: 'table', module: this,
applies: ['object', 'context'], callback: 'truncate_table',
category: 'Truncate', priority: 3, label: gettext('Truncate'),
category: gettext('Truncate'), priority: 3, label: gettext('Truncate'),
icon: 'fa fa-eraser', enable : 'canCreate',
},{
name: 'truncate_table_cascade', node: 'table', module: this,
applies: ['object', 'context'], callback: 'truncate_table_cascade',
category: 'Truncate', priority: 3, label: gettext('Truncate Cascade'),
category: gettext('Truncate'), priority: 3, label: gettext('Truncate Cascade'),
icon: 'fa fa-eraser', enable : 'canCreate',
},{
// To enable/disable all triggers for the table
name: 'enable_all_triggers', node: 'table', module: this,
applies: ['object', 'context'], callback: 'enable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Enable All'),
category: gettext('Trigger(s)'), priority: 4, label: gettext('Enable All'),
icon: 'fa fa-check', enable : 'canCreate_with_trigger_enable',
},{
name: 'disable_all_triggers', node: 'table', module: this,
applies: ['object', 'context'], callback: 'disable_triggers_on_table',
category: 'Trigger(s)', priority: 4, label: gettext('Disable All'),
category: gettext('Trigger(s)'), priority: 4, label: gettext('Disable All'),
icon: 'fa fa-times', enable : 'canCreate_with_trigger_disable',
},{
name: 'reset_table_stats', node: 'table', module: this,

View File

@ -338,7 +338,7 @@ function(gettext, _, $, Backbone, Backform, Backgrid, Alertify, pgAdmin, pgNode)
titleTmpl = _.template([
'<div class=\'subnode-header\'>',
'<span class=\'control-label\'><%-label%></span>',
'<button class=\'btn btn-sm-sq btn-secondary add fa fa-plus\' title=\'' + _('Add new row') + '\' <%=canAdd ? \'\' : \'disabled="disabled"\'%>><span class="sr-only">Add new row</span></button>',
'<button class=\'btn btn-sm-sq btn-secondary add fa fa-plus\' title=\'' + gettext('Add new row') + '\' <%=canAdd ? \'\' : \'disabled="disabled"\'%>><span class="sr-only">' + gettext('Add new row') + '</span></button>',
'</div>'].join('\n')),
$gridBody =
$('<div class=\'pgadmin-control-group backgrid form-group col-12 object subnode\'></div>').append(

View File

@ -15,7 +15,7 @@
<input class="custom-control-input" id="save_password" name="save_password" type="checkbox"
{% if not config.ALLOW_SAVE_PASSWORD %}disabled{% endif %}
>
<label class="custom-control-label" for="save_password">Save Password</label>
<label class="custom-control-label" for="save_password">{{ _('Save Password') }}</label>
</div>
</div>
</div>

View File

@ -35,7 +35,7 @@
<input class="custom-control-input" id="save_password" name="save_password" type="checkbox"
{% if not config.ALLOW_SAVE_PASSWORD %}disabled{% endif %}
>
<label class="custom-control-label" for="save_password" class="ml-1">Save Password</label>
<label class="custom-control-label" for="save_password" class="ml-1">{{ _('Save Password') }}</label>
</div>
</div>
</div>

View File

@ -183,7 +183,7 @@ define([
}
// Initialize a new Grid instance
that.grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: gridSchema.columns,
collection: that.collection,
className: 'backgrid table presentation table-bordered table-noouter-border table-hover',

View File

@ -216,7 +216,7 @@ define('pgadmin.browser.node', [
callback: 'show_script',
priority: 4,
label: type_label,
category: 'Scripts',
category: gettext('Scripts'),
data: {
'script': stype,
},

View File

@ -113,7 +113,7 @@ define([
url_with_id: false,
select2: {
allowClear: true,
placeholder: 'Select an item...',
placeholder: gettext('Select an item...'),
width: 'style',
},
}),
@ -256,7 +256,7 @@ define([
},
select2: {
allowClear: true,
placeholder: 'Select an item...',
placeholder: gettext('Select an item...'),
width: 'style',
templateResult: formatNode,
templateSelection: formatNode,
@ -375,7 +375,7 @@ define([
url_with_id: false,
select2: {
allowClear: true,
placeholder: 'Select an item...',
placeholder: gettext('Select an item...'),
width: 'style',
},
opt: {
@ -510,7 +510,7 @@ define([
return res;
},
select2: {
placeholder: 'Select an item...',
placeholder: gettext('Select an item...'),
width: 'style',
templateResult: formatNode,
templateSelection: formatNode,
@ -555,7 +555,7 @@ define([
return res;
},
select2: {
placeholder: 'Select an item...',
placeholder: gettext('Select an item...'),
width: 'style',
templateResult: formatNode,
templateSelection: formatNode,
@ -570,7 +570,7 @@ define([
url_with_id: false,
select2: {
allowClear: true,
placeholder: 'Select an item...',
placeholder: gettext('Select an item...'),
width: 'style',
multiple: true,
},

View File

@ -2,7 +2,7 @@
<div>
<div><b>{{ content_text|safe }}</b></div>
<div class="input-group row py-2">
<label for="password" class="col-sm-2 col-form-label">Password</label>
<label for="password" class="col-sm-2 col-form-label">{{ _('Password') }}</label>
<div class="col-sm-10">
<input type="password" class="form-control" id="password" name="password">
</div>

View File

@ -673,7 +673,7 @@ define('pgadmin.dashboard', [
// Set up the grid
var grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: columns,
collection: data,
className: 'backgrid presentation table table-bordered table-noouter-border table-hover',

View File

@ -87,7 +87,7 @@
<div class="input-group-prepend">
<span class="input-group-text fa fa-search" id="labelSearch"></span>
</div>
<input type="search" class="form-control" id="txtGridSearch" placeholder="Search" aria-label="Search" aria-describedby="labelSearch">
<input type="search" class="form-control" id="txtGridSearch" placeholder="{{ _('Search') }}" aria-label="Search" aria-describedby="labelSearch">
</div>
<button id="btn_refresh" type="button" class="btn btn-secondary btn-navtab-inline" title="{{ _('Refresh') }}" aria-label="{{ _('Refresh') }}">
<span class="fa fa-refresh" aria-hidden="true"></span>

View File

@ -311,8 +311,8 @@ define('misc.bgprocess', [
</div>
<div class="pg-bg-etime my-auto mr-2"></div>
<div class="ml-auto">
<button class="btn btn-secondary pg-bg-more-details"><span class="fa fa-info-circle" role="img"></span>&nbsp;${gettext('More details...')}</button>
<button class="btn btn-danger bg-process-stop"><span class="fa fa-times-circle" role="img"></span>&nbsp;${gettext('Stop Process')}</button>
<button class="btn btn-secondary pg-bg-more-details"><span class="fa fa-info-circle" role="img"></span>&nbsp;` + gettext('More details...') + `</button>
<button class="btn btn-danger bg-process-stop"><span class="fa fa-times-circle" role="img"></span>&nbsp;` + gettext('Stop Process') + `</button>
</div>
</div>
<div class="pg-bg-status py-1">
@ -393,7 +393,7 @@ define('misc.bgprocess', [
is_new = true;
panel = this.panel =
pgBrowser.BackgroundProcessObsorver.create_panel();
panel.title('Process Watcher - ' + self.type_desc);
panel.title(gettext('Process Watcher - %s', self.type_desc));
panel.focus();
}
@ -419,7 +419,7 @@ define('misc.bgprocess', [
setTimeout(function() {
self.logs[0].scrollTop = self.logs[0].scrollHeight;
});
self.logs_loading = $(`<li class="pg-bg-res-out loading-logs">${gettext('Loading process logs...')}</li>`);
self.logs_loading = $('<li class="pg-bg-res-out loading-logs">' + gettext('Loading process logs...') + '</li>');
self.logs.append(self.logs_loading);
// set bgprocess detailed description
$header.find('.bg-detailed-desc').html(self.detailed_desc);

View File

@ -75,7 +75,7 @@ define('misc.dependencies', [
var $container = this.dependenciesPanel.layout().scene().find('.pg-panel-content'),
$gridContainer = $container.find('.pg-panel-dependencies-container'),
grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: [{
name: 'type',
label: gettext('Type'),

View File

@ -76,7 +76,7 @@ define('misc.dependents', [
var $container = this.dependentsPanel.layout().scene().find('.pg-panel-content'),
$gridContainer = $container.find('.pg-panel-dependents-container'),
grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: [{
name: 'type',
label: gettext('Type'),

View File

@ -1258,12 +1258,12 @@ define([
}
select_box = `<div class='change_file_types d-flex align-items-center p-1'>
<div>
${gettext('Show hidden files and folders')}?
<input type='checkbox' id='show_hidden' onclick='pgAdmin.FileUtils.handleClick(this)' tabindex='0'>
<div>` +
gettext('Show hidden files and folders?') +
`<input type='checkbox' id='show_hidden' onclick='pgAdmin.FileUtils.handleClick(this)' tabindex='0'>
</div>
<div class="ml-auto">
<label class="my-auto">${gettext('Format')}</label>
<label class="my-auto">` + gettext('Format') + `</label>
<select name='type' tabindex='0'>${fileFormats}</select>
<div>`;
}

View File

@ -282,7 +282,7 @@ define('misc.statistics', [
}
self.grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: self.columns,
collection: self.collection,
className: GRID_CLASSES,

View File

@ -609,11 +609,11 @@ define([
if(this.$el.find('.toggle.btn').hasClass('off')) {
this.$el.find('.sr-value').text(`
${label}, ${offText}, ${gettext('Toggle button')}
${label}, ${offText}, ` + gettext('Toggle button') + `
`);
} else {
this.$el.find('.sr-value').text(`
${label}, ${onText}, ${gettext('Toggle button')}
${label}, ${onText}, ` + gettext('Toggle button') + `
`);
}
},
@ -1295,7 +1295,7 @@ define([
gridHeader = _.template([
'<div class="subnode-header">',
' <span class="control-label pg-el-sm-10" id="<%=cId%>"><%-label%></span>',
' <button aria-label="' + _('Add new row') + '" class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="' + _('Add new row') + '"><%-add_label%></button>',
' <button aria-label="' + gettext('Add new row') + '" class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> title="' + gettext('Add new row') + '"><%-add_label%></button>',
'</div>',
].join('\n')),
gridBody = $('<div class="pgadmin-control-group backgrid form-group pg-el-12 object subnode "></div>').append(
@ -1582,7 +1582,7 @@ define([
var self = this,
gridHeader = ['<div class=\'subnode-header\'>',
' <span class=\'control-label pg-el-sm-10\'>' + data.label + '</span>',
' <button aria-label="' + _('Add') + '" class=\'btn btn-sm-sq btn-secondary add fa fa-plus\' title=\'' + _('Add new row') + '\'></button>',
' <button aria-label="' + gettext('Add') + '" class=\'btn btn-sm-sq btn-secondary add fa fa-plus\' title=\'' + gettext('Add new row') + '\'></button>',
'</div>',
].join('\n'),
gridBody = $('<div class=\'pgadmin-control-group backgrid form-group pg-el-12 object subnode\'></div>').append(gridHeader);

View File

@ -432,7 +432,7 @@ define([
if (editable) {
this.$el.html(
'<i class=\'fa fa-pencil-square subnode-edit-in-process\' title=\'' + _('Edit row') + '\' aria-label=\'' + _('Edit row') + '\'></i>'
'<i class=\'fa fa-pencil-square subnode-edit-in-process\' title=\'' + gettext('Edit row') + '\' aria-label=\'' + gettext('Edit row') + '\'></i>'
);
let body = $(this.$el).parents()[1],
container = $(body).find('.tab-content:first > .tab-pane.active:first');
@ -451,7 +451,7 @@ define([
},
render: function() {
this.$el.empty();
this.$el.html('<i class=\'fa fa-pencil-square-o\' title=\'' + _('Edit row') + '\' aria-label=\'' + _('Edit row') + '\'></i>');
this.$el.html('<i class=\'fa fa-pencil-square-o\' title=\'' + gettext('Edit row') + '\' aria-label=\'' + gettext('Edit row') + '\'></i>');
this.delegateEvents();
if (this.grabFocus)
this.$el.trigger('focus');
@ -555,7 +555,7 @@ define([
var self = this;
this.$el.empty();
$(this.$el).attr('tabindex', 0);
this.$el.html('<i aria-label="' + _('Delete row') + '" class=\'fa fa-trash\' title=\'' + _('Delete row') + '\'></i>');
this.$el.html('<i aria-label="' + gettext('Delete row') + '" class=\'fa fa-trash\' title=\'' + gettext('Delete row') + '\'></i>');
// Listen for Tab/Shift-Tab key
this.$el.on('keydown', function(e) {
// with keyboard navigation on space key, mark row for deletion

View File

@ -87,7 +87,7 @@ function shortcut_title(title, shortcut) {
* shortcut object is browser.get_preference().value
*/
function shortcut_accesskey_title(title, shortcut) {
return `${title} (${gettext('accesskey')} + ${shortcut_key(shortcut)})`;
return `${title} (` + gettext('accesskey') + ` + ${shortcut_key(shortcut)})`;
}

View File

@ -8,6 +8,7 @@
//////////////////////////////////////////////////////////////
import moment from 'moment';
import gettext from 'sources/gettext';
export function calculateQueryRunTime(startTime, endTime) {
let total_ms = moment(endTime).diff(startTime);
@ -26,9 +27,9 @@ export function calculateQueryRunTime(startTime, endTime) {
hrs = parseInt(mins/60);
mins = mins%60;
result = (hrs>0 ? hrs + ' hr ': '')
+ (mins>0 ? mins + ' min ': '')
+ (hrs<=0 && secs>0 ? secs + ' secs ': '')
+ (hrs<=0 && mins<=0 ? total_ms + ' msec ':'');
result = (hrs>0 ? hrs + ' ' + gettext('hr') + ' ': '')
+ (mins>0 ? mins + ' ' + gettext('min') + ' ': '')
+ (hrs<=0 && secs>0 ? secs + ' ' + gettext('secs') + ' ': '')
+ (hrs<=0 && mins<=0 ? total_ms + ' ' + gettext('msec') + ' ':'');
return result.trim();
}

View File

@ -139,7 +139,7 @@ let FilterDialog = {
`<div id="show_filter_progress" class="pg-sp-container sql-editor-busy-fetching d-none">
<div class="pg-sp-content">
<div class="row"><div class="col-12 pg-sp-icon sql-editor-busy-icon"></div></div>
<div class="row"><div class="col-12 pg-sp-text sql-editor-busy-text">${gettext('Loading data...')}</div></div>
<div class="row"><div class="col-12 pg-sp-text sql-editor-busy-text">` + gettext('Loading data...') + `</div></div>
</div>
</div>`
).appendTo($container);

View File

@ -59,9 +59,9 @@ export default class QueryHistory {
this.parentNode.empty()
.removeClass('d-flex')
.append(
`<div role="status" class='pg-panel-message'>${gettext(
'No history found'
)}</div>`
'<div role="status" class="pg-panel-message">' +
gettext('No history found') +
'</div>'
);
} else {
this.parentNode.empty().addClass('d-flex');

View File

@ -87,10 +87,10 @@ export default class QueryHistoryDetails {
updateCopyButton(copied) {
if (copied) {
this.$copyBtn.addClass('was-copied').removeClass('copy-all');
this.$copyBtn.text('Copied!');
this.$copyBtn.text(gettext('Copied!'));
} else {
this.$copyBtn.addClass('copy-all').removeClass('was-copied');
this.$copyBtn.text('Copy');
this.$copyBtn.text(gettext('Copy'));
}
}
@ -106,14 +106,14 @@ export default class QueryHistoryDetails {
};
this.$metaData.empty().append(
`<div class='metadata'>
${itemTemplate(this.formatDate(this.entry.start_time), 'Date')}
${itemTemplate(
'<div class="metadata">' +
itemTemplate(this.formatDate(this.entry.start_time), gettext('Date')) +
itemTemplate(
this.entry.row_affected.toLocaleString(),
'Rows Affected'
)}
${itemTemplate(this.entry.total_time, 'Duration')}
</div>`
gettext('Rows Affected')
) +
itemTemplate(this.entry.total_time, gettext('Duration')) +
'</div>'
);
}
@ -179,7 +179,7 @@ export default class QueryHistoryDetails {
</div>
<div class='message-block'>
<div class='message'>
<div class='message-header'>Messages</div>
<div class='message-header'>` + gettext('Messages') + `</div>
<div class='content'></div>
</div>
</div>

View File

@ -252,11 +252,11 @@ export class QueryHistoryEntries {
<div class="toggle-and-history-container">
<div class="query-history-toggle">
<label class="control-label">
${gettext('Show queries generated internally by pgAdmin')}?
` + gettext('Show queries generated internally by pgAdmin?') + `
</label>
<input id="generated-queries-toggle" type="checkbox"
class="pgadmin-controls" data-style="quick"
data-size="mini" data-on="${gettext('Yes')}" data-off="${gettext('No')}"
data-size="mini" data-on="` + gettext('Yes') + '" data-off="' + gettext('No') + `"
data-onstyle="success" data-offstyle="ternary" checked>
</div>
<div id='query_list' class='query-history' tabindex='0'></div>

View File

@ -97,7 +97,7 @@ let queryToolNotifications = {
// Set up the grid
let notifications_grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: gridCols,
collection: queryToolNotifications.collection,
className: 'backgrid presentation table table-bordered table-hover table-noouter-border table-bottom-border',

View File

@ -98,7 +98,7 @@ export class BackupDialogWrapper extends DialogWrapper {
const node = this.pgBrowser.Nodes[selectedTreeNodeData._type];
if (this.dialogTitle === null) {
const title = `Backup (${node.label}: ${selectedTreeNodeData.label})`;
let title = gettext('Backup (%s: %s)', node.label, selectedTreeNodeData.label);
this.main(title);
}

View File

@ -1047,7 +1047,7 @@ define([
// Initialize a new Grid instance
var stack_grid = this.stack_grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: stackGridCols,
row: Backgrid.Row.extend({
events: {
@ -1112,7 +1112,7 @@ define([
// Initialize a new Grid instance
var result_grid = this.result_grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: resultGridCols,
collection: new ResultsCollection(result),
className: 'backgrid table table-bordered table-noouter-border table-bottom-border',
@ -1190,7 +1190,7 @@ define([
// Initialize a new Grid instance
var variable_grid = this.variable_grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: gridCols,
collection: new VariablesCollection(my_obj),
className: 'backgrid table table-bordered table-noouter-border table-bottom-border',
@ -1276,7 +1276,7 @@ define([
// Initialize a new Grid instance
var param_grid = this.param_grid = new Backgrid.Grid({
emptyText: 'No data found',
emptyText: gettext('No data found'),
columns: paramGridCols,
collection: new ParametersCollection(param_obj),
className: 'backgrid table table-bordered table-noouter-border table-bottom-border',

View File

@ -251,7 +251,7 @@ define([
DbObjectFilter: function(coll) {
var clientSideFilter = this.clientSideFilter = new Backgrid.Extension.ClientSideFilter({
collection: coll,
placeholder: _('Search by object type or name'),
placeholder: gettext('Search by object type or name'),
// The model fields to search for matches
fields: ['object_type', 'name'],
@ -697,11 +697,11 @@ define([
*/
var dbObjectTypePage = self.dbObjectTypePage = new pgBrowser.WizardPage({
id: 1,
page_title: _('Object Selection (step 1 of 3)'),
page_title: gettext('Object Selection (step 1 of 3)'),
disable_prev: true,
disable_next: true,
show_description: '',
show_progress_bar: _('Please wait while fetching records...'),
show_progress_bar: gettext('Please wait while fetching records...'),
model: newModel,
view: new(function() {
@ -735,13 +735,13 @@ define([
$(`
<div class="db_objects_container pg-el-xs-12">
<div class="db_objects_header d-flex py-1">
<div>${_('Please select the objects to grant privileges to from the list below.')}</div>
<div>` + gettext('Please select the objects to grant privileges to from the list below.') + `</div>
<div class="db_objects_filter ml-auto">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text fa fa-search" id="labelSearch"></span>
</div>
<input type="search" class="form-control" id="txtGridSearch" placeholder="Search" aria-label="Search" aria-describedby="labelSearch">
<input type="search" class="form-control" id="txtGridSearch" placeholder="` + gettext('Search') + `" aria-label="Search" aria-describedby="labelSearch">
</div>
</div>
</div>
@ -822,8 +822,8 @@ define([
// Wizard for Privelege control
var privilegePage = self.privilegePage = new pgBrowser.WizardPage({
id: 2,
page_title: _('Privilege Selection (step 2 of 3)'),
show_description: _('Please add the required privileges for the selected objects.'),
page_title: gettext('Privilege Selection (step 2 of 3)'),
show_description: gettext('Please add the required privileges for the selected objects.'),
disable_next: true,
model: newModel,
@ -1021,7 +1021,7 @@ define([
//Create SqlField Object
var sqlField = new Backform.Field({
id: 'sqltab',
label: _('Sql Tab'),
label: gettext('Sql Tab'),
/**
Extend 'SqlTabControl' to define new
@ -1091,8 +1091,8 @@ define([
// Wizard for SQL tab control
var reviewSQLPage = self.reviewSQLPage = new pgBrowser.WizardPage({
id: 3,
page_title: _('Final (Review Selection) (step 3 of 3)'),
show_description: _('The SQL below will be executed on the ' +
page_title: gettext('Final (Review Selection) (step 3 of 3)'),
show_description: gettext('The SQL below will be executed on the ' +
'database server to grant the selected privileges. ' +
'Please click on <b>Finish</b> to complete the process.'),
model: newModel,
@ -1151,7 +1151,7 @@ define([
*/
self.wizard = new(pgBrowser.Wizard.extend({
options: {
title: _('Grant Wizard'),
title: gettext('Grant Wizard'),
/* Main Wizard Title */
width: '',
height: '',

View File

@ -266,7 +266,7 @@ def create_maintenance_job(sid, did):
# Return response
return make_json_response(
data={'job_id': jid, 'status': True,
'info': 'Maintenance job created.'}
'info': _('Maintenance job created.')}
)

View File

@ -36,7 +36,7 @@ class SchemaDiffModule(PgAdminModule):
A module class for Schema Diff derived from PgAdminModule.
"""
LABEL = "Schema Diff"
LABEL = gettext("Schema Diff")
def get_own_menuitems(self):
return {}
@ -439,7 +439,7 @@ def compare(trans_id, source_sid, source_did, source_scid,
comparison_result = []
diff_model_obj.set_comparison_info("Comparing objects...", 0)
diff_model_obj.set_comparison_info(gettext("Comparing objects..."), 0)
update_session_diff_transaction(trans_id, session_obj,
diff_model_obj)
@ -451,7 +451,8 @@ def compare(trans_id, source_sid, source_did, source_scid,
for node_name, node_view in all_registered_nodes.items():
view = SchemaDiffRegistry.get_node_view(node_name)
if hasattr(view, 'compare'):
msg = "Comparing " + view.blueprint.COLLECTION_LABEL
msg = gettext('Comparing {0}').\
format(gettext(view.blueprint.COLLECTION_LABEL))
diff_model_obj.set_comparison_info(msg, total_percent)
# Update the message and total percentage in session object
update_session_diff_transaction(trans_id, session_obj,
@ -468,7 +469,7 @@ def compare(trans_id, source_sid, source_did, source_scid,
comparison_result = comparison_result + res
total_percent = total_percent + node_percent
msg = "Successfully compare the specified schemas."
msg = gettext("Successfully compare the specified schemas.")
total_percent = 100
diff_model_obj.set_comparison_info(msg, total_percent)
# Update the message and total percentage done in session object
@ -501,7 +502,7 @@ def poll(trans_id):
msg, diff_percentage = diff_model_obj.get_comparison_info()
if diff_percentage == 100:
diff_model_obj.set_comparison_info("Comparing objects...", 0)
diff_model_obj.set_comparison_info(gettext("Comparing objects..."), 0)
update_session_diff_transaction(trans_id, session_obj,
diff_model_obj)

View File

@ -12,6 +12,7 @@
import copy
from flask import render_template
from flask_babelex import gettext
from pgadmin.utils.driver import get_driver
from config import PG_DEFAULT_DRIVER
from pgadmin.utils.ajax import internal_server_error
@ -86,7 +87,7 @@ class SchemaDiffObjectCompare:
return compare_dictionaries(self, source_params, target_params,
target_schema, source, target,
self.node_type,
self.blueprint.COLLECTION_LABEL,
gettext(self.blueprint.COLLECTION_LABEL),
self.keys_to_ignore)
def ddl_compare(self, **kwargs):

View File

@ -7,6 +7,8 @@
#
##########################################################################
from flask_babelex import gettext
class SchemaDiffModel(object):
"""
@ -30,7 +32,7 @@ class SchemaDiffModel(object):
**kwargs : N number of parameters
"""
self._comparison_result = dict()
self._comparison_msg = 'Comparision started...'
self._comparison_msg = gettext('Comparision started...')
self._comparison_percentage = 0
def clear_data(self):

View File

@ -289,11 +289,11 @@ let SchemaDiffHeaderView = Backform.Form.extend({
},
template: _.template(`
<div class="row pgadmin-control-group">
<div class="col-1 control-label">Select Source</div>
<div class="col-1 control-label">` + gettext('Select Source') + `</div>
<div class="col-6 source row"></div>
</div>
<div class="row pgadmin-control-group">
<div class="col-1 control-label">Select Target</div>
<div class="col-1 control-label">` + gettext('Select Target') + `</div>
<div class="col-6 target row"></div>
<div class="col-5 target-buttons">
<div class="action-btns d-flex">
@ -421,9 +421,9 @@ let SchemaDiffFooterView = Backform.Form.extend({
template: {
'content': _.template(`
<div class="pg-el-sm-12 row <%=contentClass%>">
<div class="pg-el-sm-4 ddl-source">Source</div>
<div class="pg-el-sm-4 ddl-target">Target</div>
<div class="pg-el-sm-4 ddl-diff">Difference
<div class="pg-el-sm-4 ddl-source">` + gettext('Source') + `</div>
<div class="pg-el-sm-4 ddl-target">` + gettext('Target') + `</div>
<div class="pg-el-sm-4 ddl-diff">` + gettext('Difference') + `
</div>
</div>
</div>

View File

@ -85,7 +85,7 @@ define('pgadmin.schemadiff', [
})
.done(function(res) {
self.trans_id = res.data.schemaDiffTransId;
res.data.panel_title = 'Schema Diff (Beta)'; //TODO: Set the panel title
res.data.panel_title = gettext('Schema Diff (Beta)'); //TODO: Set the panel title
// TODO: Following function is used to test the fetching of the
// databases this should be moved to server selection event later.
self.launch_schema_diff(res.data);

View File

@ -302,11 +302,11 @@ export default class SchemaDiffUI {
var grid_width = (self.grid_width - 47) / 2 ;
var columns = [
checkboxSelector.getColumnDefinition(),
{id: 'title', name: 'Schema Objects', field: 'title', minWidth: grid_width, formatter: formatColumnTitle},
{id: 'status', name: 'Comparison Result', field: 'status', minWidth: grid_width},
{id: 'label', name: 'Schema Objects', field: 'label', width: 0, minWidth: 0, maxWidth: 0,
{id: 'title', name: gettext('Schema Objects'), field: 'title', minWidth: grid_width, formatter: formatColumnTitle},
{id: 'status', name: gettext('Comparison Result'), field: 'status', minWidth: grid_width},
{id: 'label', name: gettext('Schema Objects'), field: 'label', width: 0, minWidth: 0, maxWidth: 0,
cssClass: 'really-hidden', headerCssClass: 'really-hidden'},
{id: 'type', name: 'Schema Objects', field: 'type', width: 0, minWidth: 0, maxWidth: 0,
{id: 'type', name: gettext('Schema Objects'), field: 'type', width: 0, minWidth: 0, maxWidth: 0,
cssClass: 'really-hidden', headerCssClass: 'really-hidden'},
{id: 'id', name: 'id', field: 'id', width: 0, minWidth: 0, maxWidth: 0,
cssClass: 'really-hidden', headerCssClass: 'really-hidden' },
@ -462,10 +462,10 @@ export default class SchemaDiffUI {
.done(function (res) {
let msg = res.data.compare_msg;
if (res.data.diff_percentage != 100) {
msg = msg + ' (this may take a few minutes)...';
msg = msg + gettext(' (this may take a few minutes)...');
}
msg = msg + '<br>'+ res.data.diff_percentage + '% completed.';
msg = msg + '<br>' + gettext('%s completed.', res.data.diff_percentage + '%');
$('#diff_fetching_data').find('.schema-diff-busy-text').html(msg);
})
.fail(function (xhr) {

View File

@ -2237,7 +2237,7 @@ define('tools.querytool', [
self.trigger('pgadmin-sqleditor:loading-icon:hide');
self.gridView.set_editor_title(`(${gettext('Obtaining connection...')} ${_.unescape(url_params.title)}`);
self.gridView.set_editor_title('(' + gettext('Obtaining connection...') + ` ${_.unescape(url_params.title)}`);
let afterConn = function() {
let enableBtns = [];

View File

@ -212,9 +212,9 @@ def RegisterQueryToolPreferences(self):
'CSV_output', 'csv_quoting',
gettext("CSV quoting"), 'options', 'strings',
category_label=gettext('CSV Output'),
options=[{'label': 'None', 'value': 'none'},
{'label': 'All', 'value': 'all'},
{'label': 'Strings', 'value': 'strings'}],
options=[{'label': gettext('None'), 'value': 'none'},
{'label': gettext('All'), 'value': 'all'},
{'label': gettext('Strings'), 'value': 'strings'}],
select2={
'allowClear': False,
'tags': False
@ -240,7 +240,7 @@ def RegisterQueryToolPreferences(self):
options=[{'label': ';', 'value': ';'},
{'label': ',', 'value': ','},
{'label': '|', 'value': '|'},
{'label': 'Tab', 'value': '\t'}],
{'label': gettext('Tab'), 'value': '\t'}],
select2={
'allowClear': False,
'tags': True
@ -262,9 +262,9 @@ def RegisterQueryToolPreferences(self):
'Results_grid', 'results_grid_quoting',
gettext("Result copy quoting"), 'options', 'strings',
category_label=gettext('Results grid'),
options=[{'label': 'None', 'value': 'none'},
{'label': 'All', 'value': 'all'},
{'label': 'Strings', 'value': 'strings'}],
options=[{'label': gettext('None'), 'value': 'none'},
{'label': gettext('All'), 'value': 'all'},
{'label': gettext('Strings'), 'value': 'strings'}],
select2={
'allowClear': False,
'tags': False
@ -290,7 +290,7 @@ def RegisterQueryToolPreferences(self):
options=[{'label': ';', 'value': ';'},
{'label': ',', 'value': ','},
{'label': '|', 'value': '|'},
{'label': 'Tab', 'value': '\t'}],
{'label': gettext('Tab'), 'value': '\t'}],
select2={
'allowClear': False,
'tags': True

View File

@ -27,7 +27,7 @@ define([
userFilter = function(collection) {
return (new Backgrid.Extension.ClientSideFilter({
collection: collection,
placeholder: _('Filter by email'),
placeholder: gettext('Filter by email'),
// How long to wait after typing has stopped before searching can start
wait: 150,
}));
@ -763,7 +763,7 @@ define([
<div class="input-group-prepend">
<span class="input-group-text fa fa-search" id="labelSearch"></span>
</div>
<input type="search" class="form-control" id="txtGridSearch" placeholder="Search" aria-label="Search" aria-describedby="labelSearch" />
<input type="search" class="form-control" id="txtGridSearch" placeholder="` + gettext('Search') + `" aria-label="Search" aria-describedby="labelSearch" />
</div>
<button id="btn_refresh" type="button" class="btn btn-secondary btn-navtab-inline add" title="Add">
<span class="fa fa-plus "></span>