[services-*] Fix translations
- Strings like "{} the {} with {}" are terrible for translators: - no context - no possibility to re-order grammatical units - substituting in English parts-of-speech is going to make a mess - Write the strings out with explicitly named substitutions, no part-of-speech substitution, and better formatting.
This commit is contained in:
parent
879c5e3cee
commit
946c5a493f
@ -56,6 +56,22 @@ class OpenrcController:
|
||||
self.initdDir = libcalamares.job.configuration['initdDir']
|
||||
self.runlevelsDir = libcalamares.job.configuration['runlevelsDir']
|
||||
|
||||
|
||||
def make_failure_description(self, state, name, runlevel):
|
||||
"""
|
||||
Returns a generic "could not <foo>" failure message, specialized
|
||||
for the action @p state and the specific service @p name in @p runlevel.
|
||||
"""
|
||||
if state == "add":
|
||||
description = _("Cannot add service {name!s} to run-level {level!s}.")
|
||||
elif state == "del":
|
||||
description = _("Cannot remove service {name!s} from run-level {level!s}.")
|
||||
else:
|
||||
description = _("Unknown service-action <code>{arg!s}</code> for service {name!s} in run-level {level!s}.")
|
||||
|
||||
return description.format(arg=state, name=name, level=runlevel)
|
||||
|
||||
|
||||
def update(self, state):
|
||||
"""
|
||||
Call rc-update for each service listed
|
||||
@ -83,19 +99,28 @@ class OpenrcController:
|
||||
warning("Cannot {} service {} to {}".format(state, name, runlevel))
|
||||
warning("rc-update returned error code {!s}".format(ec))
|
||||
if mandatory:
|
||||
return (_("Cannot {} service {} to {}").format(state, name, runlevel),
|
||||
_("rc-update {} call in chroot returned error code {}").format(state, ec)
|
||||
title = _("Cannot modify service")
|
||||
diagnostic = _("<code>rc-update {arg!s}</code> call in chroot returned error code {num!s}.").format(arg=state, num=ec)
|
||||
return (title,
|
||||
self.make_failure_description(state, name, runlevel) + " " + diagnostic
|
||||
)
|
||||
else:
|
||||
warning("Target runlevel {} does not exist for {}.".format(runlevel, name))
|
||||
if mandatory:
|
||||
return (_("Target runlevel {} does not exist for {}.").format(runlevel, name),
|
||||
_("No {} found.").format(runlevel_path))
|
||||
title = _("Target runlevel does not exist")
|
||||
diagnostic = _("The path for runlevel {level!s} is <code>{path!s}</code>, which does not exist.").format(level=runlevel, path=runlevel_path)
|
||||
|
||||
return (title,
|
||||
self.make_failure_description(state, name, runlevel) + " " + diagnostic
|
||||
)
|
||||
else:
|
||||
warning("Target service {} does not exist in {}.".format(name, self.initdDir))
|
||||
if mandatory:
|
||||
return (_("Target service {} does not exist.").format(name),
|
||||
_("No {} found.").format(service_path))
|
||||
title = _("Target service does not exist")
|
||||
diagnostic = _("The path for service {name!s} is <code>{path!s}</code>, which does not exist.").format(name=name, path=service_path)
|
||||
return (title,
|
||||
self.make_failure_description(state, name, runlevel) + " " + diagnostic
|
||||
)
|
||||
|
||||
|
||||
def run(self):
|
||||
|
@ -65,8 +65,24 @@ def systemctl(targets, command, suffix):
|
||||
"systemctl {} call in chroot returned error code {}".format(command, ec)
|
||||
)
|
||||
if mandatory:
|
||||
return (_("Cannot {} systemd {} {}").format(command, suffix, name),
|
||||
_("systemctl {} call in chroot returned error code {}").format(command, ec)
|
||||
title = _("Cannot modify service")
|
||||
diagnostic = _("<code>systemctl {arg!s}</code> call in chroot returned error code {num!s}.").format(arg=command, num=ec)
|
||||
|
||||
if command == "enable" and suffix == ".service":
|
||||
description = _("Cannot enable systemd service <code>{name!s}</code>.")
|
||||
elif command == "enable" and suffix == ".target":
|
||||
description = _("Cannot enable systemd target <code>{name!s}</code>.")
|
||||
elif command == "disable" and suffix == ".service":
|
||||
description = _("Cannot enable systemd service <code>{name!s}</code>.")
|
||||
elif command == "disable" and suffix == ".target":
|
||||
description = _("Cannot disable systemd target <code>{name!s}</code>.")
|
||||
elif command == "mask":
|
||||
description = _("Cannot mask systemd unit <code>{name!s}</code>.")
|
||||
else:
|
||||
description = _("Unknown systemd commands <code>{command!s}</code> and <code>{suffix!s}</code> for unit {name!s}.")
|
||||
|
||||
return (title,
|
||||
description.format(name=name, command=command, suffix=suffix) + " " + diagnostic
|
||||
)
|
||||
return None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user