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

@@ -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,