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

@@ -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) {