Some more gettext() usage fixes: 

- fixed `%` vs. `.format()`
  - unified texts and usage `%s` vs. `{}`/`{0}`
  - improved text sentences for translate
  - added gettext for next texts
This commit is contained in:
Libor M
2020-04-20 11:19:09 +05:30
committed by Akshay Joshi
parent 8bdfa18efb
commit 36a3d4e53b
22 changed files with 48 additions and 54 deletions

View File

@@ -502,8 +502,8 @@ def create_app(app_name=None):
svr_port = winreg.QueryValueEx(inst_key, 'Port')[0]
svr_discovery_id = inst_id
svr_comment = gettext(
"Auto-detected %s installation with the data "
"directory at {}").format(
"Auto-detected {0} installation with the data "
"directory at {1}").format(
winreg.QueryValueEx(
inst_key, 'Display Name'
)[0],

View File

@@ -378,7 +378,7 @@ class EventTriggerView(PGChildNodeView):
status=400,
success=0,
errormsg=gettext(
"Could not find the required parameter {}.").format(err)
"Could not find the required parameter ({}).").format(err)
)
try:
sql = render_template(
@@ -636,7 +636,7 @@ class EventTriggerView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter {}."
"Could not find the required parameter ({})."
).format(arg)
)
sql = render_template(

View File

@@ -216,9 +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 ({})."
).format(arg)
)
try:

View File

@@ -211,9 +211,8 @@ class DomainConstraintView(PGChildNodeView):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
arg
)
"Could not find the required parameter ({})."
).format(arg)
)
try:

View File

@@ -260,9 +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 ({})."
).format(arg)
)
try:

View File

@@ -213,7 +213,7 @@ define('pgadmin.node.fts_configuration', [
' </div>',
' <div class="col-6" header="token"></div>',
' <div class="col-2">',
' <button class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> ><span class="sr-only">Add Token</span></button>',
' <button class="btn btn-sm-sq btn-secondary add fa fa-plus" <%=canAdd ? "" : "disabled=\'disabled\'"%> ><span class="sr-only">' + gettext('Add Token') + '</span></button>',
' </div>',
' </div>',
' </div>',

View File

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

View File

@@ -277,9 +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 ({})."
).format(arg)
)
list_params = []

View File

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

View File

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

View File

@@ -341,8 +341,8 @@ class RuleView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." % arg
)
"Could not find the required parameter ({})."
).format(arg)
)
try:
SQL = render_template("/".join(

View File

@@ -542,9 +542,8 @@ class TriggerView(PGChildNodeView, SchemaDiffObjectCompare):
status=410,
success=0,
errormsg=gettext(
"Could not find the required parameter (%s)." %
required_args[arg]
)
"Could not find the required parameter ({})."
).format(required_args[arg])
)
# Adding parent into data dict, will be using it while creating sql

View File

@@ -190,8 +190,7 @@ define('pgadmin.node.pga_jobstep', [
id: 'jstconnstr', label: gettext('Connection string'), type: 'text',
deps: ['jstkind', 'jstconntype'], disabled: function(m) {
return !m.get('jstkind') || m.get('jstconntype');
}, helpMessage: gettext('Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = \'a value\'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.<br>For more information, please see the documentation on %s',
'<a href="https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING" target="_blank">libpq connection strings</a>'
}, helpMessage: gettext('Please specify the connection string for the remote database server. Each parameter setting is in the form keyword = value. Spaces around the equal sign are optional. To write an empty value, or a value containing spaces, surround it with single quotes, e.g., keyword = \'a value\'. Single quotes and backslashes within the value must be escaped with a backslash, i.e., \' and \\.<br>For more information, please see the documentation on <a href="https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING" target="_blank">libpq connection strings</a>.'
), mode: ['create', 'edit'],
},{
id: 'jstonerror', label: gettext('On error'), cell: 'select2',

View File

@@ -3,7 +3,7 @@
<div><span class="font-weight-bold" >{{ _('Please enter the password for the user \'{0}\' to connect the server - "{1}"').format(username,
server_label) }}</span></div>
<div class="input-group row py-2">
<label for="password" class="col-sm-2 col-form-label" aria-hidden="true">Password</label>
<label for="password" class="col-sm-2 col-form-label" aria-hidden="true">{{ _('Password') }}</label>
<div class="col-sm-10">
<input id="password" class="form-control" name="password" type="password">
</div>

View File

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

View File

@@ -226,7 +226,7 @@ define('pgadmin.browser', [
width: 500,
isCloseable: false,
isPrivate: true,
content: '<label for="sql-textarea" class="sr-only">SQL Code</label><div class="sql_textarea"><textarea id="sql-textarea" name="sql-textarea" title="'+gettext('SQL Code')+'"></textarea></div>',
content: '<label for="sql-textarea" class="sr-only">' + gettext('SQL Code') + '</label><div class="sql_textarea"><textarea id="sql-textarea" name="sql-textarea" title="' + gettext('SQL Code') + '"></textarea></div>',
}),
// Dependencies of the object
'dependencies': new pgAdmin.Browser.Panel({

View File

@@ -1552,7 +1552,7 @@ define([
'<div id="multiple-uploads" class="dropzone flex-grow-1 d-flex p-1">'+
'<div class="dz-default dz-message d-none"></div>'+
'</div>' +
'<div class="prompt-info">Drop files here to upload. ' + lg.file_size_limit +
'<div class="prompt-info">' + gettext('Drop files here to upload.') + ' ' + lg.file_size_limit +
config.upload.fileSizeLimit + ' ' + lg.mb + '.</div>',
path = $('.currentpath').val(),
filesizelimit = config.upload.fileSizeLimit,

View File

@@ -490,44 +490,44 @@ define('pgadmin.misc.explain', [
if ('Join Filter' in _planData) {
node_extra_info.push(
'<strong>Join Filter</strong>: ' + _.escape(_planData['Join Filter'])
'<strong>' + gettext('Join Filter') + '</strong>: ' + _.escape(_planData['Join Filter'])
);
}
if ('Filter' in _planData) {
node_extra_info.push('<strong>Filter</strong>: ' + _.escape(_planData['Filter']));
node_extra_info.push('<strong>' + gettext('Filter') + '</strong>: ' + _.escape(_planData['Filter']));
}
if ('Index Cond' in _planData) {
node_extra_info.push('<strong>Index Cond</strong>: ' + _.escape(_planData['Index Cond']));
node_extra_info.push('<strong>' + gettext('Index Cond') + '</strong>: ' + _.escape(_planData['Index Cond']));
}
if ('Hash Cond' in _planData) {
node_extra_info.push('<strong>Hash Cond</strong>: ' + _.escape(_planData['Hash Cond']));
node_extra_info.push('<strong>' + gettext('Hash Cond') + '</strong>: ' + _.escape(_planData['Hash Cond']));
}
if ('Rows Removed by Filter' in _planData) {
node_extra_info.push(
'<strong>Rows Removed by Filter</strong>: ' +
'<strong>' + gettext('Rows Removed by Filter') + '</strong>: ' +
_.escape(_planData['Rows Removed by Filter'])
);
}
if ('Peak Memory Usage' in _planData) {
var buffer = [
'<strong>Buckets</strong>:', _.escape(_planData['Hash Buckets']),
'<strong>Batches</strong>:', _.escape(_planData['Hash Batches']),
'<strong>Memory Usage</strong>:', _.escape(_planData['Peak Memory Usage']), 'kB',
'<strong>' + gettext('Buckets') + '</strong>:', _.escape(_planData['Hash Buckets']),
'<strong>' + gettext('Batches') + '</strong>:', _.escape(_planData['Hash Batches']),
'<strong>' + gettext('Memory Usage') + '</strong>:', _.escape(_planData['Peak Memory Usage']), 'kB',
].join(' ');
node_extra_info.push(buffer);
}
if ('Recheck Cond' in _planData) {
node_extra_info.push('<strong>Recheck Cond</strong>: ' + _planData['Recheck Cond']);
node_extra_info.push('<strong>' + gettext('Recheck Cond') + '</strong>: ' + _planData['Recheck Cond']);
}
if ('Exact Heap Blocks' in _planData) {
node_extra_info.push('<strong>Heap Blocks</strong>: exact=' + _planData['Exact Heap Blocks']);
node_extra_info.push('<strong>' + gettext('Heap Blocks') + '</strong>: exact=' + _planData['Exact Heap Blocks']);
}
info.rows.push(_explainRowTemplate({

View File

@@ -1081,7 +1081,7 @@ define([
},
render: function() {
this.$el.empty();
this.$el.html('<label><a><span style=\'font-weight:normal;\'>Array Values</a></span></label> <button class=\'btn-sm btn-secondary add\'>Add</button>');
this.$el.html('<label><a><span style=\'font-weight:normal;\'>' + gettext('Array Values') + '</a></span></label> <button class=\'btn-sm btn-secondary add\'>' + gettext('Add') + '</button>');
this.delegateEvents();
return this;
},
@@ -2055,7 +2055,7 @@ define([
$(`<div class="custom-control custom-checkbox custom-checkbox-no-label ${align_center?'text-center':''}">
<input tabindex="0" type="checkbox" class="custom-control-input" id="${id}" ${!editable?'disabled':''} ${checked?'checked':''}/>
<label class="custom-control-label" for="${id}">
<span class="sr-only">Select<span>
<span class="sr-only">` + gettext('Select') + `<span>
</label>
</div>`)
);

View File

@@ -128,7 +128,7 @@ export default class QueryHistoryDetails {
this.$errMsgBlock.removeClass('d-none');
this.$errMsgBlock.empty().append(
`<div class='history-error-text'>
<span>Error Message</span> ${_.escape(this.parseErrorMessage(this.entry.message))}
<span>` + gettext('Error Message') + `</span> ${_.escape(this.parseErrorMessage(this.entry.message))}
</div>`
);
} else {

View File

@@ -126,7 +126,7 @@
'<div class="custom-control custom-checkbox custom-checkbox-no-label">',
' <input tabindex="0" type="checkbox" class="custom-control-input" id="'+ id +'" />',
' <label class="custom-control-label" for="'+ id +'">',
' <span class="sr-only">Select All<span>',
' <span class="sr-only">' + gettext('Select All') + '<span>',
' </label>',
'</div>'
].join('\n'));

View File

@@ -150,8 +150,7 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
if(count != 0 && !count) {
count = gettext('Unknown');
}
this.searchResultCount.innerHTML = count + ' ' +
(count===1 ? gettext('match found.'): gettext('matches found.'));
this.searchResultCount.innerHTML = (count===1 ? gettext('%s match found.', count): gettext('%s matches found.', count));
}
showOtherInfo(rowno) {
@@ -256,8 +255,7 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
if(!rowData.show_node) {
this.showMessage(
gettext('%s objects are disabled in the browser.', rowData.type_label) + ' ' +
gettext('You can enable them in the') + ' <a class="pref-dialog-link">' + gettext('preferences dialog') + '</a>.',
gettext('%s objects are disabled in the browser. You can enable them in the <a class="pref-dialog-link">preferences dialog</a>.', rowData.type_label),
true,
(statusBar)=>{
statusBar.querySelector('.pref-dialog-link').addEventListener('click', ()=>{
@@ -465,7 +463,7 @@ export default class SearchObjectsDialogWrapper extends DialogWrapper {
).then((res)=>{
let types = [{
id: 'all',
text: 'All types',
text: gettext('All types'),
}];
for (const key of Object.keys(res.data.data).sort()) {