1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-15 12:19:02 +00:00

Update translatable strings: use named placeholders

This commit is contained in:
dmiller
2025-05-20 15:25:12 +00:00
parent 3591d0d970
commit f84f4b9879
11 changed files with 143 additions and 136 deletions

View File

@@ -83,7 +83,7 @@ UNKNOWN_SERVICE_COLOR = '#d5d5d5'
TRACE_HEADER = ['TTL', 'RTT', 'IP', _('Hostname')]
TRACE_TEXT = _(
"Traceroute on port <b>%s/%s</b> totalized <b>%d</b> known hops.")
"Traceroute on port <b>%(port)s/%(proto)s</b> took <b>%(hops)d</b> known hops.")
NO_TRACE_TEXT = _("No traceroute information available.")
@@ -98,7 +98,7 @@ OSCLASS_HEADER = ['%', _('Vendor'), _('Type'), _('Family'), _('Version')]
USED_PORTS_TEXT = "%d/%s %s"
TCP_SEQ_NOTE = _("""\
<b>*</b> TCP sequence <i>index</i> equal to %d and <i>difficulty</i> is "%s".\
<b>*</b> TCP sequence <i>index</i> equal to %(index)d and <i>difficulty</i> is "%(difficulty)s".\
""")
@@ -220,7 +220,7 @@ class ServicesPage(Gtk.Notebook):
if key in ['servicefp']:
text = _('[%d] service: %s') % (port['id'], key)
text = _('[%(port)d] service: %(servicefp)s') % (port['id'], key)
self.__select_combobox.append_text(text)
self.__text.append(port['service'][key])
@@ -420,10 +420,7 @@ class SystemPage(BWScrolledWindow):
self.__uptime_label = BWSectionLabel(_('Last boot:'))
seconds = self.__node.get_info('uptime')['seconds']
lastboot = self.__node.get_info('uptime')['lastboot']
text = _('%s (%s seconds).') % (lastboot, seconds)
text = _('%(lastboot)s (%(seconds)s seconds).') % self.__node.get_info('uptime')
self.__uptime_value = BWLabel(text)
self.__uptime_value.set_selectable(True)
@@ -732,9 +729,9 @@ class TraceroutePage(BWVBox):
self.__trace_scroll.add_with_viewport(self.__trace_treeview)
self.__trace_info = (self.__node.get_info('trace')['port'],
self.__node.get_info('trace')['protocol'],
len(self.__node.get_info('trace')['hops']))
self.__trace_info = {port = self.__node.get_info('trace')['port'],
proto = self.__node.get_info('trace')['protocol'],
hops = len(self.__node.get_info('trace')['hops'])}
self.__trace_label = BWLabel(TRACE_TEXT % self.__trace_info)
self.__trace_label.set_use_markup(True)

View File

@@ -347,13 +347,13 @@ class HostInfo(object):
services = []
for p in self.ports:
services.append({
"service_name": p.get("service_name", _("unknown")),
"service_name": p.get("service_name", "unknown"),
"portid": p.get("portid", ""),
"service_version": p.get("service_version",
_("Unknown version")),
"service_product": p.get("service_product", ""),
"service_extrainfo": p.get("service_extrainfo", ""),
"port_state": p.get("port_state", _("unknown")),
"port_state": p.get("port_state", "unknown"),
"protocol": p.get("protocol", "")
})
return services
@@ -639,8 +639,10 @@ in epoch format!")
if scan_name:
return scan_name
if self.profile_name and self.get_targets():
return _("%s on %s") % (self.profile_name,
join_quoted(self.get_targets()))
return _("%(profile_name)s on %(targets)s") % {
profile_name = self.profile_name,
targets = join_quoted(self.get_targets())
}
return self.get_nmap_command()
def set_scan_name(self, scan_name):

View File

@@ -195,7 +195,7 @@ class Profile(UmitConfigParser, object):
self.read(user_profile)
except ConfigParser_Error as e:
# No scan profiles found is not a reason to crash.
self.add_profile(_("Profiles not found"),
self.add_profile(_("No profiles found"),
command="nmap",
description=_("The {} file is missing or corrupted"
).format(user_profile))

View File

@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Zenmap\n"
"Report-Msgid-Bugs-To: dev@nmap.org\n"
"POT-Creation-Date: 2025-05-16 19:56+0000\n"
"POT-Creation-Date: 2025-05-19 16:32+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
@@ -16,18 +16,13 @@ msgstr ""
msgid "Unknown Host"
msgstr ""
#: zenmapCore/NmapParser.py:350 zenmapCore/NmapParser.py:356
#: zenmapGUI/ScanOpenPortsPage.py:400
msgid "unknown"
msgstr ""
#: zenmapCore/NmapParser.py:353
msgid "Unknown version"
msgstr ""
#: zenmapCore/NmapParser.py:642
#, python-format
msgid "%s on %s"
msgid "%(profile_name)s on %(targets)s"
msgstr ""
#: zenmapCore/UmitOptionParser.py:77
@@ -65,7 +60,7 @@ msgid ""
msgstr ""
#: zenmapCore/UmitConf.py:198
msgid "Profiles not found"
msgid "No profiles found"
msgstr ""
#: zenmapCore/UmitConf.py:200
@@ -187,7 +182,7 @@ msgstr ""
msgid "Cannot open selected file"
msgstr ""
#: zenmapGUI/DiffCompare.py:208
#: zenmapGUI/DiffCompare.py:209
#, python-format
msgid ""
"This error occurred while trying to open the file:\n"
@@ -334,7 +329,7 @@ msgstr ""
msgid "Search for a scan result"
msgstr ""
#: zenmapGUI/MainWindow.py:272 zenmapGUI/ScanInterface.py:874
#: zenmapGUI/MainWindow.py:272 zenmapGUI/ScanInterface.py:876
msgid "Filter Hosts"
msgstr ""
@@ -487,19 +482,19 @@ msgstr ""
#, python-format
msgid ""
"An error occurred when saving to\n"
"%s\n"
"The error was: %s."
"%(configfile)s\n"
"The error was: %(error)s."
msgstr ""
#: zenmapGUI/MainWindow.py:944
#: zenmapGUI/MainWindow.py:947
msgid "Can't find documentation files"
msgstr ""
#: zenmapGUI/MainWindow.py:945
#: zenmapGUI/MainWindow.py:948
#, python-format
msgid ""
"There was an error loading the documentation file %s (%s). See the online "
"documentation at %s."
"There was an error loading the documentation file %(helpfile)s (%(error)s). "
"See the online documentation at %(url)s."
msgstr ""
#: zenmapGUI/ScanInterface.py:379
@@ -568,32 +563,32 @@ msgid ""
"%s"
msgstr ""
#: zenmapGUI/ScanInterface.py:687
#: zenmapGUI/ScanInterface.py:688
#, python-format
msgid "%d/%d hosts shown"
msgstr ""
#: zenmapGUI/ScanInterface.py:924
msgid "Nmap Output"
msgstr ""
#: zenmapGUI/ScanInterface.py:925
msgid "Ports / Hosts"
msgid "%(num_shown)d/%(total)d hosts shown"
msgstr ""
#: zenmapGUI/ScanInterface.py:926
msgid "Topology"
msgid "Nmap Output"
msgstr ""
#: zenmapGUI/ScanInterface.py:927
msgid "Host Details"
msgid "Ports / Hosts"
msgstr ""
#: zenmapGUI/ScanInterface.py:928
msgid "Topology"
msgstr ""
#: zenmapGUI/ScanInterface.py:929
msgid "Host Details"
msgstr ""
#: zenmapGUI/ScanInterface.py:930
msgid "Scans"
msgstr ""
#: zenmapGUI/ScanInterface.py:949
#: zenmapGUI/ScanInterface.py:951
msgid "No host selected."
msgstr ""
@@ -894,7 +889,7 @@ msgstr ""
#: zenmapGUI/About.py:132
#, python-format
msgid "About %s and %s"
msgid "About %(nmap)s and %(zenmap)s"
msgstr ""
#: zenmapGUI/About.py:151
@@ -907,34 +902,35 @@ msgstr ""
#: zenmapGUI/About.py:156
#, python-format
msgid ""
"%s is a multi-platform graphical %s frontend and results viewer. It was "
"originally derived from %s."
"%(zenmap)s is a multi-platform graphical %(nmap)s frontend and results "
"viewer. It was originally derived from %(umit)s."
msgstr ""
#: zenmapGUI/About.py:162
#: zenmapGUI/About.py:164
#, python-format
msgid ""
"%s is an %s GUI created as part of the Nmap/Google Summer of Code program."
"%(umit)s is a %(nmap)s GUI created as part of the Nmap/Google Summer of Code "
"program."
msgstr ""
#: zenmapGUI/About.py:164 zenmapGUI/About.py:206
#: zenmapGUI/About.py:166 zenmapGUI/About.py:208
#, python-format
msgid "%s credits"
msgstr ""
#: zenmapGUI/About.py:248
#: zenmapGUI/About.py:250
msgid "Written by"
msgstr ""
#: zenmapGUI/About.py:250
#: zenmapGUI/About.py:252
msgid "Design"
msgstr ""
#: zenmapGUI/About.py:254
#: zenmapGUI/About.py:256
msgid "Contributors"
msgstr ""
#: zenmapGUI/About.py:256
#: zenmapGUI/About.py:258
msgid "Translation"
msgstr ""
@@ -982,7 +978,7 @@ msgstr ""
#, python-format
msgid ""
"Topology is disabled because too many hosts can cause it\n"
"to run slowly. The limit is %d hosts and there are %d."
"to run slowly. The limit is %(limit)d hosts and there are %(num)d."
msgstr ""
#: zenmapGUI/FileChoosers.py:78
@@ -1103,53 +1099,54 @@ msgstr ""
#: zenmapGUI/App.py:221
#, python-format
msgid ""
"There was an error creating the directory %s or one of the files in it. The "
"directory is created by copying the contents of %s. The specific error was\n"
"There was an error creating the directory %(dirname)s or one of the files in "
"it. The directory is created by copying the contents of %(configdir)s. The "
"specific error was\n"
"\n"
"%s\n"
"%(error)s\n"
"\n"
"%s needs to create this directory to store information such as the list of "
"scan profiles. Check for access to the directory and try again."
msgstr ""
#: zenmapGUI/App.py:246
msgid "Error parsing the configuration file"
"%(zenmap)s needs to create this directory to store information such as the "
"list of scan profiles. Check for access to the directory and try again."
msgstr ""
#: zenmapGUI/App.py:247
#, python-format
msgid ""
"There was an error parsing the configuration file %s. The specific error "
"was\n"
"\n"
"%s\n"
"\n"
"%s can continue without this file but any information in it will be ignored "
"until it is repaired."
msgid "Error parsing the configuration file"
msgstr ""
#: zenmapGUI/App.py:261
#: zenmapGUI/App.py:248
#, python-format
msgid ""
"There was an error parsing the configuration file %(filename)s. The specific "
"error was\n"
"\n"
"%(error)s\n"
"\n"
"%(zenmap)s can continue without this file but any information in it will be "
"ignored until it is repaired."
msgstr ""
#: zenmapGUI/App.py:263
msgid "Restore default configuration?"
msgstr ""
#: zenmapGUI/App.py:262
#: zenmapGUI/App.py:264
#, python-format
msgid ""
"To avoid further errors parsing the configuration file %s, you can copy the "
"default configuration from %s.\n"
"To avoid further errors parsing the configuration file %(filename)s, you can "
"copy the default configuration from %(dirname)s.\n"
"\n"
"Do this now? "
msgstr ""
#: zenmapGUI/App.py:321
#: zenmapGUI/App.py:323
#, python-format
msgid ""
"You are trying to run %s with a non-root user!\n"
"You are trying to run %(zenmap)s with a non-root user!\n"
"\n"
"Some %s options need root privileges to work."
"Some %(nmap)s options need root privileges to work."
msgstr ""
#: zenmapGUI/App.py:326
#: zenmapGUI/App.py:328
msgid "Non-root user"
msgstr ""
@@ -1312,7 +1309,8 @@ msgstr ""
#: radialnet/gui/NodeNotebook.py:86
#, python-format
msgid "Traceroute on port <b>%s/%s</b> totalized <b>%d</b> known hops."
msgid ""
"Traceroute on port <b>%(port)s/%(proto)s</b> took <b>%(hops)d</b> known hops."
msgstr ""
#: radialnet/gui/NodeNotebook.py:88
@@ -1334,8 +1332,8 @@ msgstr ""
#: radialnet/gui/NodeNotebook.py:100
#, python-format
msgid ""
"<b>*</b> TCP sequence <i>index</i> equal to %d and <i>difficulty</i> is \"%s"
"\"."
"<b>*</b> TCP sequence <i>index</i> equal to %(index)d and <i>difficulty</i> "
"is \"%(difficulty)s\"."
msgstr ""
#: radialnet/gui/NodeNotebook.py:134
@@ -1351,7 +1349,7 @@ msgstr ""
msgid "Ports (%s)"
msgstr ""
#: radialnet/gui/NodeNotebook.py:196 radialnet/gui/NodeNotebook.py:707
#: radialnet/gui/NodeNotebook.py:196 radialnet/gui/NodeNotebook.py:704
msgid "<unknown>"
msgstr ""
@@ -1361,7 +1359,7 @@ msgstr ""
#: radialnet/gui/NodeNotebook.py:223
#, python-format
msgid "[%d] service: %s"
msgid "[%(port)d] service: %(servicefp)s"
msgstr ""
#: radialnet/gui/NodeNotebook.py:228
@@ -1401,32 +1399,32 @@ msgstr ""
msgid "Hostname:"
msgstr ""
#: radialnet/gui/NodeNotebook.py:426
#: radialnet/gui/NodeNotebook.py:423
#, python-format
msgid "%s (%s seconds)."
msgid "%(lastboot)s (%(seconds)s seconds)."
msgstr ""
#: radialnet/gui/NodeNotebook.py:489
#: radialnet/gui/NodeNotebook.py:486
msgid "Match"
msgstr ""
#: radialnet/gui/NodeNotebook.py:530 radialnet/gui/NodeNotebook.py:580
#: radialnet/gui/NodeNotebook.py:527 radialnet/gui/NodeNotebook.py:577
msgid "Class"
msgstr ""
#: radialnet/gui/NodeNotebook.py:538
#: radialnet/gui/NodeNotebook.py:535
msgid "Used ports:"
msgstr ""
#: radialnet/gui/NodeNotebook.py:561
#: radialnet/gui/NodeNotebook.py:558
msgid "Fingerprint"
msgstr ""
#: radialnet/gui/NodeNotebook.py:581
#: radialnet/gui/NodeNotebook.py:578
msgid "Values"
msgstr ""
#: radialnet/gui/NodeNotebook.py:585
#: radialnet/gui/NodeNotebook.py:582
msgid "TCP Timestamp"
msgstr ""

View File

@@ -129,8 +129,8 @@ class About(HIGDialog):
have roughly the same feel as Gtk.AboutDialog."""
def __init__(self):
HIGDialog.__init__(self)
self.set_title(_("About %s and %s") % (
NMAP_DISPLAY_NAME, APP_DISPLAY_NAME))
self.set_title(_("About %(nmap)s and %(zenmap)s") % {
nmap = NMAP_DISPLAY_NAME, zenmap = APP_DISPLAY_NAME })
self.vbox.set_border_width(12)
self.vbox.set_spacing(12)
@@ -153,14 +153,16 @@ class About(HIGDialog):
self.vbox.pack_start(entry, True, True, 0)
entry = _program_entry(APP_DISPLAY_NAME, APP_WEB_SITE, _(
"%s is a multi-platform graphical %s frontend and results viewer. "
"It was originally derived from %s.") % (
APP_DISPLAY_NAME, NMAP_DISPLAY_NAME, UMIT_DISPLAY_NAME))
"%(zenmap)s is a multi-platform graphical %(nmap)s frontend and results viewer. "
"It was originally derived from %(umit)s.") % {
zenmap = APP_DISPLAY_NAME,
nmap = NMAP_DISPLAY_NAME,
umit = UMIT_DISPLAY_NAME})
self.vbox.pack_start(entry, True, True, 0)
entry = _program_entry(UMIT_DISPLAY_NAME, UMIT_WEB_SITE, _(
"%s is an %s GUI created as part of the Nmap/Google Summer "
"of Code program.") % (UMIT_DISPLAY_NAME, NMAP_DISPLAY_NAME))
"%(umit)s is a %(nmap)s GUI created as part of the Nmap/Google Summer "
"of Code program.") % {umit = UMIT_DISPLAY_NAME, nmap = NMAP_DISPLAY_NAME})
button = Gtk.Button.new_with_label(_("%s credits") % UMIT_DISPLAY_NAME)
button.connect("clicked", self._show_umit_credits)
entry.hbox.pack_start(button, False, True, 0)

View File

@@ -219,17 +219,18 @@ def run():
message_format=_(
"Error creating the per-user configuration directory"),
secondary_text=_("""\
There was an error creating the directory %s or one of the files in it. \
The directory is created by copying the contents of %s. \
There was an error creating the directory %(dirname)s or one of the files in it. \
The directory is created by copying the contents of %(configdir)s. \
The specific error was
%s
%(error)s
%s needs to create this directory to store information such as the list of \
scan profiles. Check for access to the directory and try again.""") % (
repr(Path.user_config_dir), repr(Path.config_dir),
repr(str(e)), APP_DISPLAY_NAME
)
%(zenmap)s needs to create this directory to store information such as the list of \
scan profiles. Check for access to the directory and try again.""") % {
dirname = repr(Path.user_config_dir),
configdir = repr(Path.config_dir),
error = repr(str(e)), zenmap = APP_DISPLAY_NAME
}
)
error_dialog.run()
error_dialog.destroy()
@@ -245,13 +246,14 @@ scan profiles. Check for access to the directory and try again.""") % (
error_dialog = HIGAlertDialog(
message_format=_("Error parsing the configuration file"),
secondary_text=_("""\
There was an error parsing the configuration file %s. \
There was an error parsing the configuration file %(filename)s. \
The specific error was
%s
%(error)s
%s can continue without this file but any information in it will be ignored \
until it is repaired.""") % (Path.user_config_file, str(e), APP_DISPLAY_NAME)
%(zenmap)s can continue without this file but any information in it will be ignored \
until it is repaired.""") % {
filename = Path.user_config_file, error = str(e), zenmap = APP_DISPLAY_NAME}
)
error_dialog.run()
error_dialog.destroy()
@@ -260,11 +262,11 @@ until it is repaired.""") % (Path.user_config_file, str(e), APP_DISPLAY_NAME)
type=Gtk.MessageType.QUESTION,
message_format=_("Restore default configuration?"),
secondary_text=_("""\
To avoid further errors parsing the configuration file %s, \
you can copy the default configuration from %s.
To avoid further errors parsing the configuration file %(filename)s, \
you can copy the default configuration from %(dirname)s.
Do this now? \
""") % (Path.user_config_file, global_config_path),
""") % {filename = Path.user_config_file, dirname = global_config_path},
)
repair_dialog.add_button(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
repair_dialog.set_default_response(Gtk.ResponseType.CANCEL)
@@ -318,10 +320,10 @@ Do this now? \
class NonRootWarning (HIGAlertDialog):
def __init__(self):
warning_text = _('''You are trying to run %s with a non-root user!
warning_text = _('''You are trying to run %(zenmap)s with a non-root user!
Some %s options need root privileges to work.''') % (
APP_DISPLAY_NAME, NMAP_DISPLAY_NAME)
Some %(nmap)s options need root privileges to work.''') % {
zenmap = APP_DISPLAY_NAME, nmap = NMAP_DISPLAY_NAME}
HIGAlertDialog.__init__(self, message_format=_('Non-root user'),
secondary_text=warning_text)

View File

@@ -205,9 +205,9 @@ class ScanChooser(HIGVBox):
alert = HIGAlertDialog(
message_format='<b>%s</b>' % _(
'Cannot open selected file'),
secondary_text=_("""\
This error occurred while trying to open the file:
%s""") % str(e))
secondary_text=_(
"This error occurred while trying to open the file:\n%s"
) % str(e))
alert.run()
alert.destroy()
return False

View File

@@ -896,9 +896,12 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
message_format=_("Can't save Zenmap configuration"),
# newline before path to help avoid weird line wrapping
secondary_text=_(
'An error occurred when saving to\n%s'
'\nThe error was: %s.'
) % (Path.user_config_file, config_parser.failed))
'An error occurred when saving to\n%(configfile)s'
'\nThe error was: %(error)s.'
) % {
configfile = Path.user_config_file,
error = config_parser.failed
})
alert.run()
alert.destroy()
@@ -943,9 +946,10 @@ This scan has not been run yet. Start the scan with the "Scan" button first.'))
d = HIGAlertDialog(parent=self,
message_format=_("Can't find documentation files"),
secondary_text=_("""\
There was an error loading the documentation file %s (%s). See the \
online documentation at %s.\
""") % (doc_path, str(e), APP_DOCUMENTATION_SITE))
There was an error loading the documentation file %(helpfile)s (%(error)s). See the \
online documentation at %(url)s.\
""") % {
helpfile = doc_path, error = str(e), url = APP_DOCUMENTATION_SITE})
d.run()
d.destroy()

View File

@@ -684,9 +684,11 @@ class ScanInterface(HIGVBox):
self.host_view_selection.select_iter(
self.scan_result.scan_host_view.host_list.get_iter_first())
self.filter_bar.set_information_text(_("%d/%d hosts shown") %
(len(self.inventory.get_hosts_up()),
len(NetworkInventory.get_hosts_up(self.inventory))))
self.filter_bar.set_information_text(
_("%(num_shown)d/%(total)d hosts shown") % {
num_shown = len(self.inventory.get_hosts_up()),
total = len(NetworkInventory.get_hosts_up(self.inventory))
})
mode = self.scan_result.scan_host_view.mode
if mode == ScanHostsView.HOST_MODE:

View File

@@ -397,7 +397,7 @@ class HostOpenPorts(HIGVBox):
p["host"].get_hostname(),
int(p.get('portid', "0")),
p.get('protocol', ""),
p.get('port_state', _("unknown")),
p.get('port_state', "unknown"),
get_version_string(p)
]
)

View File

@@ -139,8 +139,8 @@ class TopologyPage(HIGVBox):
self.slow_label.set_text(_("""\
Topology is disabled because too many hosts can cause it
to run slowly. The limit is %d hosts and there are %d.\
""" % (SLOW_LIMIT, len(hosts_up))))
to run slowly. The limit is %(limit)d hosts and there are %(num)d.\
""" % {limit = SLOW_LIMIT, num = len(hosts_up)}))
if len(hosts_up) <= SLOW_LIMIT:
self.radialnet.show()