Fixed gettext usage: 

- fixed gettext usage with .format() only for original text with %s
  - fixed typos
  - fixed translation yes/no buttons in the dialog.
  - improved translating sentences without "connecting" words (eg. see web/pgadmin/dashboard/static/js/dashboard.js,
     word 'cancel' needs to be translated in the Czech language as 'zrušit' but in another sentence as 'zrušení')
  - added gettext for text translations.
This commit is contained in:
Libor M
2020-04-10 14:52:41 +05:30
committed by Akshay Joshi
parent e238ecf182
commit 6a9af07f7a
81 changed files with 231 additions and 269 deletions

View File

@@ -741,8 +741,7 @@ class ServerNode(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
if 'hostaddr' in data and data['hostaddr'] and data['hostaddr'] != '':
@@ -838,7 +837,7 @@ class ServerNode(PGChildNodeView):
status=401,
success=0,
errormsg=gettext(
u"Unable to connect to server:\n\n%s" % errmsg)
u"Unable to connect to server:\n\n%s") % errmsg
)
else:
if 'save_password' in data and data['save_password'] and \

View File

@@ -175,7 +175,7 @@ class DatabaseView(PGChildNodeView):
kwargs['sid']
)
if self.manager is None:
return gone(errormsg="Could not find the server.")
return gone(errormsg=_("Could not find the server."))
if action and action in ["drop"]:
self.conn = self.manager.connection()
@@ -567,8 +567,7 @@ class DatabaseView(PGChildNodeView):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
# The below SQL will execute CREATE DDL only
SQL = render_template(

View File

@@ -368,8 +368,7 @@ class CastView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:
sql = render_template("/".join([self.template_path, 'create.sql']),
@@ -668,8 +667,8 @@ class CastView(PGChildNodeView):
if res is None:
return gone(gettext(
"Could not generate reversed engineered SQL for the cast \
node."
"Could not generate reversed engineered SQL for the "
"cast node."
))
return ajax_response(response=res)

View File

@@ -378,8 +378,7 @@ class EventTriggerView(PGChildNodeView):
status=400,
success=0,
errormsg=gettext(
"Could not find the required parameter %s." % err
)
"Could not find the required parameter %s.") % err
)
try:
sql = render_template(
@@ -637,8 +636,7 @@ class EventTriggerView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter %s." % err
)
"Could not find the required parameter %s.") % err
)
sql = render_template(
"/".join([self.template_path, 'create.sql']),

View File

@@ -262,8 +262,7 @@ class ExtensionView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
status, res = self.conn.execute_dict(

View File

@@ -393,8 +393,7 @@ class ForeignDataWrapperView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:

View File

@@ -388,8 +388,7 @@ class ForeignServerView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:
if 'fsrvacl' in data:

View File

@@ -36,7 +36,7 @@ define('pgadmin.node.foreign_server', [
if (_.isUndefined(this.get('fsrvoption')) ||
_.isNull(this.get('fsrvoption')) ||
String(this.get('fsrvoption')).replace(/^\s+|\s+$/g, '') == '') {
var msg = 'Please enter an option name';
var msg = gettext('Please enter an option name.');
this.errorModel.set('fsrvoption', msg);
return msg;
} else {

View File

@@ -396,8 +396,7 @@ class UserMappingView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:

View File

@@ -39,7 +39,7 @@ define('pgadmin.node.user_mapping', [
if (_.isUndefined(this.get('umoption')) ||
_.isNull(this.get('umoption')) ||
String(this.get('umoption')).replace(/^\s+|\s+$/g, '') == '') {
var msg = 'Please enter an option name';
var msg = gettext('Please enter an option name.');
this.errorModel.set('umoption', msg);
return msg;
} else {

View File

@@ -37,7 +37,7 @@ define('pgadmin.node.foreign_data_wrapper', [
if (_.isUndefined(this.get('fdwoption')) ||
_.isNull(this.get('fdwoption')) ||
String(this.get('fdwoption')).replace(/^\s+|\s+$/g, '') == '') {
var msg = 'Please enter an option name';
var msg = gettext('Please enter an option name.');
this.errorModel.set('fdwoption', msg);
return msg;
} else {

View File

@@ -453,8 +453,7 @@ class LanguageView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:

View File

@@ -136,7 +136,7 @@ def check_precondition(f):
kwargs['sid']
)
if not self.manager:
return gone(errormsg="Could not find the server.")
return gone(errormsg=gettext("Could not find the server."))
self.conn = self.manager.connection(did=kwargs['did'])
# Set the template path for the SQL scripts
@@ -570,9 +570,8 @@ It may have been removed by another user.
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
required_args[arg]
)
"Could not find the required parameter (%s).") %
required_args[arg]
)
try:
self.format_request_acls(data)

View File

@@ -458,8 +458,7 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
if self._check_definition(data):
return make_json_response(

View File

@@ -216,10 +216,8 @@ class DomainView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
arg
)
)
"Could not find the required parameter (%s).")
% arg)
try:
list_params = []

View File

@@ -260,10 +260,8 @@ class ForeignTableView(PGChildNodeView, DataTypeReader,
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
arg
)
)
"Could not find the required parameter (%s).")
% arg)
try:
list_params = []

View File

@@ -422,8 +422,7 @@ class FtsConfigurationView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
# Either copy config or parser must be present in data

View File

@@ -431,7 +431,7 @@ class FtsDictionaryView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg)
"Could not find the required parameter (%s).") % arg
)
# Fetch schema name from schema oid
sql = render_template(

View File

@@ -379,8 +379,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
# Fetch schema name from schema oid
sql = render_template(
@@ -850,7 +849,7 @@ class FtsParserView(PGChildNodeView, SchemaDiffObjectCompare):
return gone(
_(
"Could not generate reversed engineered query for "
"FTS Parser node"
"FTS Parser node."
)
)

View File

@@ -354,8 +354,7 @@ class FtsTemplateView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
# Fetch schema name from schema oid
sql = render_template("/".join([self.template_path, 'schema.sql']),

View File

@@ -277,10 +277,8 @@ class FunctionView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
arg
)
)
"Could not find the required parameter (%s).")
% arg)
list_params = []
if request.method == 'GET':

View File

@@ -379,8 +379,7 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
data['schema'] = self.schema
@@ -557,9 +556,8 @@ class PackageView(PGChildNodeView, SchemaDiffObjectCompare):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
)
"Could not find the required parameter (%s).")
% arg)
SQL, name = self.getSQL(gid, sid, did, data, scid, pkgid)
# Most probably this is due to error

View File

@@ -381,8 +381,7 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:
@@ -590,9 +589,8 @@ class SequenceView(PGChildNodeView, SchemaDiffObjectCompare):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
)
"Could not find the required parameter (%s).")
% arg)
SQL, name = self.getSQL(gid, sid, did, data, scid, seid)
# Most probably this is due to error
if not isinstance(SQL, (str, unicode)):

View File

@@ -450,8 +450,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:

View File

@@ -908,8 +908,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
# Parse privilege data coming from client according to database format
@@ -1578,7 +1577,7 @@ class TableView(BaseTableView, DataTypeReader, VacuumSettings,
return make_json_response(
status=200,
info=gettext("Table rows counted: %s" % count),
info=gettext("Table rows counted: %s") % count,
data={'total_rows': count}
)

View File

@@ -392,9 +392,8 @@ class ColumnsView(PGChildNodeView, DataTypeReader):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
required_args[arg]
)
"Could not find the required parameter (%s).") %
required_args[arg]
)
# Parse privilege data coming from client according to database format

View File

@@ -511,9 +511,8 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
required_args[arg]
)
"Could not find the required parameter (%s).") %
required_args[arg]
)
# Adding parent into data dict, will be using it while creating sql
@@ -904,8 +903,8 @@ class CompoundTriggerView(PGChildNodeView, SchemaDiffObjectCompare):
if not status:
return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(gettext("""Could not find the compound
trigger in the table."""))
return gone(gettext("Could not find the compound "
"trigger in the table."))
data = dict(res['rows'][0])
# Adding parent into data dict,

View File

@@ -194,10 +194,10 @@ define('pgadmin.node.compound_trigger', [
return false;
},
options: [
{label: 'Enable', value: 'O'},
{label: 'Enable Replica', value: 'R'},
{label: 'Enable Always', value: 'A'},
{label: 'Disable', value: 'D'},
{label: gettext('Enable'), value: 'O'},
{label: gettext('Enable Replica'), value: 'R'},
{label: gettext('Enable Always'), value: 'A'},
{label: gettext('Disable'), value: 'D'},
],
control: 'select2', select2: { allowClear: false, width: '100%' },
},{

View File

@@ -476,8 +476,7 @@ class CheckConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
data['schema'] = self.schema

View File

@@ -496,16 +496,14 @@ class ExclusionConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s)." % str(arg)
)
"Could not find required parameter (%s).") % str(arg)
)
elif isinstance(data[arg], list) and len(data[arg]) < 1:
return make_json_response(
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s)." % str(arg)
)
"Could not find required parameter (%s).") % str(arg)
)
data['schema'] = self.schema

View File

@@ -506,16 +506,14 @@ class ForeignKeyConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s)." % str(arg)
)
"Could not find required parameter (%s).") % str(arg)
)
elif isinstance(data[arg], list) and len(data[arg]) < 1:
return make_json_response(
status=400,
success=0,
errormsg=_(
"Could not find required parameter (%s)." % str(arg)
)
"Could not find required parameter (%s).") % str(arg)
)
data['schema'] = self.schema

View File

@@ -287,9 +287,10 @@ class IndexConstraintView(PGChildNodeView):
return res
if len(res) == 0:
return gone(_("""Could not find the {} in the table.""".format(
"primary key" if self.constraint_type == "p" else "unique key"
)))
return gone(_("""Could not find the {} in the table.""").format(
_("primary key") if self.constraint_type == "p"
else _("unique key")
))
result = res
if cid:
@@ -386,9 +387,10 @@ class IndexConstraintView(PGChildNodeView):
return internal_server_error(errormsg=rset)
if len(rset['rows']) == 0:
return gone(_("""Could not find the {} in the table.""".format(
"primary key" if self.constraint_type == "p" else "unique key"
)))
return gone(_("""Could not find the {} in the table.""").format(
_("primary key") if self.constraint_type == "p"
else _("unique key")
))
res = self.blueprint.generate_browser_node(
rset['rows'][0]['oid'],
@@ -533,8 +535,7 @@ class IndexConstraintView(PGChildNodeView):
success=0,
errormsg=_(
"Could not find at least one required "
"parameter (%s)." % str(param)
)
"parameter (%s).") % str(param)
)
elif arg not in data:
@@ -542,8 +543,7 @@ class IndexConstraintView(PGChildNodeView):
status=400,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
data['schema'] = self.schema
@@ -824,9 +824,10 @@ class IndexConstraintView(PGChildNodeView):
if not status:
return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(_("""Could not find the {} in the table.""".format(
"primary key" if self.constraint_type == "p" else "unique key"
)))
return gone(_("""Could not find the {} in the table.""").format(
_("primary key") if self.constraint_type == "p"
else _("unique key")
))
data = res['rows'][0]
data['schema'] = self.schema
@@ -916,10 +917,10 @@ class IndexConstraintView(PGChildNodeView):
return internal_server_error(errormsg=res)
if len(res['rows']) == 0:
return gone(
_("""Could not find the {} in the table.""".format(
"primary key" if self.constraint_type == "p"
else "unique key"
))
_("""Could not find the {} in the table.""").format(
_("primary key") if self.constraint_type == "p"
else _("unique key")
)
)
result = res['rows'][0]

View File

@@ -649,7 +649,7 @@ define('pgadmin.node.primary_key', [
if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
(_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
var msg = gettext('Please specify columns for %s', gettext('Primary key'));
var msg = gettext('Please specify columns for %s.', gettext('Primary key'));
this.errorModel.set('columns', msg);
return msg;
}

View File

@@ -638,7 +638,7 @@ define('pgadmin.node.unique_constraint', [
if ((_.isUndefined(index) || String(index).replace(/^\s+|\s+$/g, '') == '') &&
(_.isUndefined(columns) || _.isNull(columns) || columns.length < 1)) {
var msg = gettext('Please specify columns for %s', gettext('Unique constraint'));
var msg = gettext('Please specify columns for %s.', gettext('Unique constraint'));
this.errorModel.set('columns', msg);
return msg;
}

View File

@@ -576,11 +576,12 @@ class IndexesView(PGChildNodeView, SchemaDiffObjectCompare):
for arg in required_args:
err_msg = None
if arg == 'columns' and len(data['columns']) < 1:
err_msg = "You must provide one or more column to create index"
err_msg = gettext("You must provide one or more column to "
"create index.")
if arg not in data:
err_msg = "Could not find the required parameter (%s)." % \
required_args[arg]
err_msg = gettext("Could not find the required parameter (%s)"
".") % required_args[arg]
# Check if we have at least one column
if err_msg is not None:
return make_json_response(

View File

@@ -60,12 +60,12 @@ function(
pgBrowser.add_menus([{
name: 'truncate_table', node: 'partition', 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: 'partition', 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

View File

@@ -196,10 +196,10 @@ define('pgadmin.node.trigger', [
return false;
},
options: [
{label: 'Enable', value: 'O'},
{label: 'Enable Replica', value: 'R'},
{label: 'Enable Always', value: 'A'},
{label: 'Disable', value: 'D'},
{label: gettext('Enable'), value: 'O'},
{label: gettext('Enable Replica'), value: 'R'},
{label: gettext('Enable Always'), value: 'A'},
{label: gettext('Disable'), value: 'D'},
],
control: 'select2', select2: { allowClear: false, width: '100%' },
},{

View File

@@ -946,9 +946,8 @@ class TypeView(PGChildNodeView, DataTypeReader, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
required_args[arg]
)
"Could not find the required parameter (%s).") %
required_args[arg]
)
# Additional checks goes here
# If type is range then check if subtype is defined or not

View File

@@ -218,9 +218,9 @@ define('pgadmin.node.type', [
else if (this.get('is_tlength')
&& !_.isUndefined(this.get('tlength'))) {
if (this.get('tlength') < this.get('min_val'))
errmsg = gettext('Length/Precision should not be less than %s', this.get('min_val'));
errmsg = gettext('Length/Precision should not be less than %s.', this.get('min_val'));
if (this.get('tlength') > this.get('max_val') )
errmsg = gettext('Length/Precision should not be greater than %s', this.get('max_val'));
errmsg = gettext('Length/Precision should not be greater than %s.', this.get('max_val'));
// If we have any error set then throw it to user
if(errmsg) {
this.errorModel.set('tlength', errmsg);
@@ -231,9 +231,9 @@ define('pgadmin.node.type', [
else if (this.get('is_precision')
&& !_.isUndefined(this.get('precision'))) {
if (this.get('precision') < this.get('min_val'))
errmsg = gettext('Scale should not be less than %s', this.get('min_val'));
errmsg = gettext('Scale should not be less than %s.', this.get('min_val'));
if (this.get('precision') > this.get('max_val'))
errmsg = gettext('Scale should not be greater than %s', this.get('max_val'));
errmsg = gettext('Scale should not be greater than %s.', this.get('max_val'));
// If we have any error set then throw it to user
if(errmsg) {
this.errorModel.set('precision', errmsg);

View File

@@ -493,8 +493,7 @@ class ViewNode(PGChildNodeView, VacuumSettings, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:
SQL, nameOrError = self.getSQL(gid, sid, did, scid, data)

View File

@@ -190,7 +190,7 @@ define('pgadmin.node.database', [
Alertify.confirm(
gettext('Disconnect the database'),
pgadminUtils.sprintf(gettext('Are you sure you want to disconnect the database - %s?'), d.label),
gettext('Are you sure you want to disconnect the database - %s?', d.label),
function() {
var data = d;
$.ajax({
@@ -228,7 +228,11 @@ define('pgadmin.node.database', [
t.unload(i);
});
},
function() { return true; });
function() { return true; }
).set('labels', {
ok: gettext('Yes'),
cancel: gettext('No'),
});
return false;
},

View File

@@ -284,8 +284,7 @@ SELECT EXISTS(
status=410,
success=0,
errormsg=_(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
status, res = self.conn.execute_void('BEGIN')

View File

@@ -305,7 +305,7 @@ define('pgadmin.node.pga_jobstep', [
!_.isUndefined(val) && !_.isNull(val) &&
String(val).replace(/^\s+|\s+$/g, '') == ''
) {
msg = gettext('Please select valid on error option .');
msg = gettext('Please select valid on error option.');
this.errorModel.set('jstonerror', msg);
} else {
this.errorModel.unset('jstonerror');

View File

@@ -363,8 +363,7 @@ class ResourceGroupView(NodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter (%s).") % arg
)
try:
# Below logic will create new resource group

View File

@@ -203,7 +203,7 @@ function(gettext, _, $, Backbone, Backform, Backgrid, Alertify, pgAdmin, pgNode)
} else if (_.isUndefined(this.get('value')) ||
_.isNull(this.get('value')) ||
String(this.get('value')).replace(/^\s+|\s+$/g, '') == '') {
msg = ('Please enter a value for the parameter.');
msg = gettext('Please enter a value for the parameter.');
this.errorModel.set('value', msg);
this.errorModel.unset('name');
} else {

View File

@@ -295,9 +295,8 @@ class TablespaceView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
required_args[arg]
)
"Could not find the required parameter (%s).") %
required_args[arg]
)
# To format privileges coming from client

View File

@@ -261,7 +261,7 @@ define('pgadmin.node.tablespace', [
self.__internal.buttons[2].element.disabled = false;
} else {
self.__internal.buttons[2].element.disabled = true;
this.errorModel.set('tblspc', gettext('Please select tablespace'));
this.errorModel.set('tblspc', gettext('Please select tablespace.'));
}
});
},

View File

@@ -74,7 +74,7 @@ class ServerType(object):
return self.spriority
def __str__(self):
return "Type: {0}, Description:{1}, Priority: {2}".format(
return _("Type: {0}, Description: {1}, Priority: {2}").format(
self.stype, self.desc, self.spriority
)
@@ -115,9 +115,9 @@ class ServerType(object):
res = 'psql'
else:
raise Exception(
_("Could not find the utility for the operation '%s'".format(
_("Could not find the utility for the operation '%s'").format(
operation
))
)
)
bin_path = self.utility_path.get()
if "$DIR" in bin_path: