Use gettext to wrap some strings.

This commit is contained in:
Akshay Joshi 2022-04-29 16:18:28 +05:30
parent 7b66777600
commit c56fe813a5
13 changed files with 42 additions and 39 deletions

View File

@ -2,7 +2,7 @@
Version 6.9
************
Release date: 2022-05-05
Release date: 2022-05-06
This release contains a number of bug fixes and new features since the release of pgAdmin4 6.8.

View File

@ -614,7 +614,7 @@ class CastView(PGChildNodeView, SchemaDiffObjectCompare):
data=data, conn=self.conn
)
else:
return "-- definition incomplete", None
return gettext("-- definition incomplete"), None
return sql, data['srctyp'] + "->" + data["trgtyp"]
@check_precondition

View File

@ -143,11 +143,11 @@ export default class CastSchema extends BaseUISchema {
{
id: 'castcontext', label: gettext('Context'), readonly: true,
options:[{
label: 'IMPLICIT', value: 'IMPLICIT',
label: gettext('IMPLICIT'), value: 'IMPLICIT',
},{
label: 'EXPLICIT', value: 'EXPLICIT',
label: gettext('EXPLICIT'), value: 'EXPLICIT',
},{
label: 'ASSIGNMENT', value: 'ASSIGNMENT',
label: gettext('ASSIGNMENT'), value: 'ASSIGNMENT',
}], type: 'select', group: gettext('Definition'),
mode:['properties', 'edit'],
controlProps: {

View File

@ -683,10 +683,10 @@ class CollationView(PGChildNodeView, SchemaDiffObjectCompare):
for arg in required_args:
if arg not in data:
return "-- missing definition"
return gettext("-- missing definition")
if self._check_definition(data):
return "-- missing definition"
return gettext("-- missing definition")
SQL = render_template("/".join([self.template_path,
self._CREATE_SQL]),

View File

@ -655,7 +655,7 @@ class SynonymView(PGChildNodeView, SchemaDiffObjectCompare):
for arg in required_args:
if arg not in data:
return "-- missing definition"
return gettext("-- missing definition")
name = data['name']
SQL = render_template("/".join([self.template_path,

View File

@ -57,7 +57,8 @@ const useStyles = makeStyles(() =>
export default function CloudWizard({ nodeInfo, nodeData }) {
const classes = useStyles();
var steps = ['Cloud Provider', 'Credentials', 'Instance Specification', 'Database Details', 'Review'];
var steps = [gettext('Cloud Provider'), gettext('Credentials'),
gettext('Instance Specification'), gettext('Database Details'), gettext('Review')];
const [currentStep, setCurrentStep] = React.useState('');
const [selectionVal, setCloudSelection] = React.useState('');
const [errMsg, setErrMsg] = React.useState('');

View File

@ -13,6 +13,7 @@ from flask_security import current_user
from pgadmin.misc.bgprocess.processes import IProcessDesc
from pgadmin.utils import html
from pgadmin.model import db, Server
from flask_babel import gettext
def get_my_ip():
@ -74,8 +75,8 @@ class CloudProcessDesc(IProcessDesc):
@property
def message(self):
return "Deployment on {0} is started for instance {1}.".format(
self.provider, self.instance_name)
return gettext("Deployment on {0} is started for instance {1}.".format(
self.provider, self.instance_name))
def details(self, cmd, args):
res = '<div>' + self.message
@ -88,4 +89,4 @@ class CloudProcessDesc(IProcessDesc):
@property
def type_desc(self):
return "Cloud Deployment"
return gettext("Cloud Deployment")

View File

@ -113,7 +113,7 @@ export default function GrantWizard({ sid, did, nodeInfo, nodeData }) {
isVisible: false
}
];
var steps = ['Object Selection', 'Privilege Selection', 'Review'];
var steps = [gettext('Object Selection'), gettext('Privilege Selection'), gettext('Review')];
const [selectedObject, setSelectedObject] = React.useState([]);
const [selectedAcl, setSelectedAcl] = React.useState({});
const [msqlData, setSQL] = React.useState('');

View File

@ -57,7 +57,7 @@ export default function ImportExportServers() {
const classes = useStyles();
const tableClasses = commonTableStyles();
var steps = ['Import/Export', 'Database Servers', 'Summary'];
var steps = [gettext('Import/Export'), gettext('Database Servers'), gettext('Summary')];
const [loaderText, setLoaderText] = React.useState('');
const [errMsg, setErrMsg] = React.useState('');
const [selectionFormData, setSelectionFormData] = React.useState({});

View File

@ -160,7 +160,7 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
{
tabs: [
LayoutHelper.getPanel({id: PANELS.QUERY, title: gettext('Query'), content: <Query />}),
LayoutHelper.getPanel({id: PANELS.HISTORY, title: 'Query History', content: <QueryHistory />,
LayoutHelper.getPanel({id: PANELS.HISTORY, title: gettext('Query History'), content: <QueryHistory />,
cached: undefined}),
],
},
@ -187,13 +187,13 @@ export default function QueryToolComponent({params, pgWindow, pgAdmin, selectedN
{
tabs: [
LayoutHelper.getPanel({
id: PANELS.DATA_OUTPUT, title: 'Data output', content: <ResultSet />,
id: PANELS.DATA_OUTPUT, title: gettext('Data output'), content: <ResultSet />,
}),
LayoutHelper.getPanel({
id: PANELS.MESSAGES, title:'Messages', content: <Messages />,
id: PANELS.MESSAGES, title: gettext('Messages'), content: <Messages />,
}),
LayoutHelper.getPanel({
id: PANELS.NOTIFICATIONS, title:'Notifications', content: <Notifications />,
id: PANELS.NOTIFICATIONS, title: gettext('Notifications'), content: <Notifications />,
}),
],
}

View File

@ -765,7 +765,7 @@ export function ResultSet() {
}
LayoutHelper.openTab(queryToolCtx.docker, {
id: PANELS.EXPLAIN,
title:'Explain',
title:gettext('Explain'),
content: <Explain plans={planJson} />,
closable: true,
}, PANELS.MESSAGES, 'after-tab', true);
@ -1147,7 +1147,7 @@ export function ResultSet() {
let selRowsData = selectedRows.size === 0 ? rows : rows.filter((r)=>selectedRows.has(rowKeyGetter(r)));
LayoutHelper.openTab(queryToolCtx.docker, {
id: PANELS.GEOMETRY,
title:'Geometry Viewer',
title:gettext('Geometry Viewer'),
content: <GeometryViewer rows={selRowsData} columns={columns} column={column} />,
closable: true,
}, PANELS.MESSAGES, 'after-tab', true);

View File

@ -59,7 +59,7 @@ export function StatusBar() {
});
eventBus.registerListener(QUERY_TOOL_EVENTS.EXECUTION_END, ()=>{
pauseTimer();
setLastTaskText('Query complete');
setLastTaskText(gettext('Query complete'));
});
eventBus.registerListener(QUERY_TOOL_EVENTS.TASK_START, (taskText, startTime)=>{
resetTimer();

View File

@ -483,8 +483,8 @@ def dump_database_servers(output_file, selected_servers,
err_msg = error_str.format(e.strerror)
return _handle_error(err_msg, from_setup)
msg = "Configuration for %s servers dumped to %s" % \
(servers_dumped, output_file.name)
msg = gettext("Configuration for %s servers dumped to %s" %
(servers_dumped, output_file.name))
print(msg)
return True, msg
@ -500,7 +500,7 @@ def validate_json_data(data, is_admin):
skip_servers = []
# Loop through the servers...
if "Servers" not in data:
return "'Servers' attribute not found in the specified file."
return gettext("'Servers' attribute not found in the specified file.")
for server in data["Servers"]:
obj = data["Servers"][server]
@ -514,13 +514,13 @@ def validate_json_data(data, is_admin):
def check_attrib(attrib):
if attrib not in obj:
return ("'%s' attribute not found for server '%s'" %
(attrib, server))
return gettext("'%s' attribute not found for server '%s'" %
(attrib, server))
return None
def check_is_integer(value):
if not isinstance(value, int):
return "Port must be integer for server '%s'" % server
return gettext("Port must be integer for server '%s'" % server)
return None
for attrib in ("Group", "Name"):
@ -547,8 +547,8 @@ def validate_json_data(data, is_admin):
if "Host" not in obj and "HostAddr" not in obj and not \
is_service_attrib_available:
return ("'Host', 'HostAddr' or 'Service' attribute "
"not found for server '%s'" % server)
return gettext("'Host', 'HostAddr' or 'Service' attribute not "
"found for server '%s'" % server)
for server in skip_servers:
del data["Servers"][server]
@ -581,11 +581,11 @@ def load_database_servers(input_file, selected_servers,
with open(file_path) as f:
data = json.load(f)
except json.decoder.JSONDecodeError as e:
return _handle_error("Error parsing input file %s: %s" %
(file_path, e), from_setup)
return _handle_error(gettext("Error parsing input file %s: %s" %
(file_path, e)), from_setup)
except Exception as e:
return _handle_error("Error reading input file %s: [%d] %s" %
(file_path, e.errno, e.strerror), from_setup)
return _handle_error(gettext("Error reading input file %s: [%d] %s" %
(file_path, e.errno, e.strerror)), from_setup)
f.close()
@ -623,8 +623,8 @@ def load_database_servers(input_file, selected_servers,
if from_setup:
print(ADD_SERVERS_MSG % (groups_added, servers_added))
return _handle_error(
"Error creating server group '%s': %s" %
(new_group.name, e), from_setup)
gettext("Error creating server group '%s': %s" %
(new_group.name, e)), from_setup)
group_id = new_group.id
groups_added = groups_added + 1
@ -695,8 +695,8 @@ def load_database_servers(input_file, selected_servers,
except Exception as e:
if from_setup:
print(ADD_SERVERS_MSG % (groups_added, servers_added))
return _handle_error("Error creating server '%s': %s" %
(new_server.name, e), from_setup)
return _handle_error(gettext("Error creating server '%s': %s" %
(new_server.name, e)), from_setup)
servers_added = servers_added + 1
@ -732,8 +732,9 @@ def clear_database_servers(load_user=current_user, from_setup=False):
try:
db.session.commit()
except Exception as e:
error_msg = "Error clearing server configuration with error (%s)" % \
str(e)
error_msg = \
gettext("Error clearing server configuration with error (%s)" %
str(e))
if from_setup:
print(error_msg)
sys.exit(1)