mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Improve translatability of cloud printer syncing texts
Here are a number of improvements to the translated texts that make it easier for the translators to translate them: * Never include layout elements such as <ul> or <li> in the translated text. The translators don't know what to do with them. Instead, leave the tags out of the translated parts and then wrap them around it in Python. * If there are replacement keys in the source text, explain all of them in the context. * Use a name within the brackets, to make it clear from context what the brackets mean and to disambiguate multiple keys if there are multiple. * No invisible whitespace (such as space at the end of a line). * Use plural forms with i18ncp if applicable (or i18np if no context is necessary). I also changed the catalogue variable to lowercase with underscores, as per our code style.
This commit is contained in:
parent
5840205442
commit
5ec57d42d0
1 changed files with 23 additions and 25 deletions
|
@ -1,5 +1,6 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Copyright (c) 2020 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
import os
|
||||
from typing import Dict, List, Optional, Set
|
||||
|
||||
|
@ -37,7 +38,7 @@ class CloudOutputDeviceManager:
|
|||
SYNC_SERVICE_NAME = "CloudOutputDeviceManager"
|
||||
|
||||
# The translation catalog for this device.
|
||||
I18N_CATALOG = i18nCatalog("cura")
|
||||
i18n_catalog = i18nCatalog("cura")
|
||||
|
||||
# Signal emitted when the list of discovered devices changed.
|
||||
discoveredDevicesChanged = Signal()
|
||||
|
@ -221,7 +222,7 @@ class CloudOutputDeviceManager:
|
|||
)
|
||||
|
||||
message = Message(
|
||||
title = self.I18N_CATALOG.i18ncp(
|
||||
title = self.i18n_catalog.i18ncp(
|
||||
"info:status",
|
||||
"New printer detected from your Ultimaker account",
|
||||
"New printers detected from your Ultimaker account",
|
||||
|
@ -234,11 +235,7 @@ class CloudOutputDeviceManager:
|
|||
message.show()
|
||||
|
||||
for idx, device in enumerate(new_devices):
|
||||
message_text = self.I18N_CATALOG.i18nc(
|
||||
"info:status", "Adding printer {} ({}) from your account",
|
||||
device.name,
|
||||
device.printerTypeName
|
||||
)
|
||||
message_text = self.i18n_catalog.i18nc("info:status %1 is printer name, %2 is printer type", "Adding printer {name} ({type}) from your account").format(name = device.name, type = device.printerTypeName)
|
||||
message.setText(message_text)
|
||||
if len(new_devices) > 1:
|
||||
message.setProgress((idx / len(new_devices)) * 100)
|
||||
|
@ -255,16 +252,12 @@ class CloudOutputDeviceManager:
|
|||
if len(new_devices) > max_disp_devices:
|
||||
num_hidden = len(new_devices) - max_disp_devices
|
||||
device_name_list = ["<li>{} ({})</li>".format(device.name, device.printerTypeName) for device in new_devices[0:max_disp_devices]]
|
||||
device_name_list.append(self.I18N_CATALOG.i18nc("info:hidden list items", "<li>... and {} others</li>", num_hidden))
|
||||
device_name_list.append("<li>" + self.i18n_catalog.i18ncp("info:{num_hidden} gets replaced by a number of printers", "... and {num_hidden} other", "... and {num_hidden} others", num_hidden).format(num_hidden = num_hidden) + "</li>")
|
||||
device_names = "".join(device_name_list)
|
||||
else:
|
||||
device_names = "".join(["<li>{} ({})</li>".format(device.name, device.printerTypeName) for device in new_devices])
|
||||
|
||||
message_text = self.I18N_CATALOG.i18nc(
|
||||
"info:status",
|
||||
"Printers added from Digital Factory:<ul>{}</ul>",
|
||||
device_names
|
||||
)
|
||||
message_text = self.i18n_catalog.i18nc("info:status", "Printers added from Digital Factory:") + "<ul>" + device_names + "</ul>"
|
||||
message.setText(message_text)
|
||||
|
||||
def _updateOutdatedMachine(self, outdated_machine: GlobalStack, new_cloud_output_device: CloudOutputDevice) -> None:
|
||||
|
@ -318,7 +311,7 @@ class CloudOutputDeviceManager:
|
|||
|
||||
# Generate message
|
||||
self._removed_printers_message = Message(
|
||||
title = self.I18N_CATALOG.i18ncp(
|
||||
title = self.i18n_catalog.i18ncp(
|
||||
"info:status",
|
||||
"A cloud connection is not available for a printer",
|
||||
"A cloud connection is not available for some printers",
|
||||
|
@ -326,27 +319,27 @@ class CloudOutputDeviceManager:
|
|||
)
|
||||
)
|
||||
device_names = "".join(["<li>{} ({})</li>".format(self._um_cloud_printers[device].name, self._um_cloud_printers[device].definition.name) for device in self.reported_device_ids])
|
||||
message_text = self.I18N_CATALOG.i18ncp(
|
||||
message_text = self.i18n_catalog.i18ncp(
|
||||
"info:status",
|
||||
"This printer is not linked to the Digital Factory:",
|
||||
"These printers are not linked to the Digital Factory:",
|
||||
len(self.reported_device_ids)
|
||||
)
|
||||
message_text += "<br/><ul>{}</ul><br/>".format(device_names)
|
||||
digital_factory_string = self.I18N_CATALOG.i18nc("info:name", "Ultimaker Digital Factory")
|
||||
digital_factory_string = self.i18n_catalog.i18nc("info:name", "Ultimaker Digital Factory")
|
||||
|
||||
message_text += self.I18N_CATALOG.i18nc(
|
||||
message_text += self.i18n_catalog.i18nc(
|
||||
"info:status",
|
||||
"To establish a connection, please visit the {website_link}".format(website_link = "<a href='https://digitalfactory.ultimaker.com/'>{}</a>.".format(digital_factory_string))
|
||||
)
|
||||
self._removed_printers_message.setText(message_text)
|
||||
self._removed_printers_message.addAction("keep_printer_configurations_action",
|
||||
name = self.I18N_CATALOG.i18nc("@action:button", "Keep printer configurations"),
|
||||
name = self.i18n_catalog.i18nc("@action:button", "Keep printer configurations"),
|
||||
icon = "",
|
||||
description = "Keep cloud printers in Ultimaker Cura when not connected to your account.",
|
||||
button_align = Message.ActionButtonAlignment.ALIGN_RIGHT)
|
||||
self._removed_printers_message.addAction("remove_printers_action",
|
||||
name = self.I18N_CATALOG.i18nc("@action:button", "Remove printers"),
|
||||
name = self.i18n_catalog.i18nc("@action:button", "Remove printers"),
|
||||
icon = "",
|
||||
description = "Remove cloud printer(s) which aren't linked to your account.",
|
||||
button_style = Message.ActionButtonStyle.SECONDARY,
|
||||
|
@ -423,9 +416,9 @@ class CloudOutputDeviceManager:
|
|||
machine.setMetaDataEntry(self.META_HOST_GUID, device.clusterData.host_guid)
|
||||
machine.setMetaDataEntry("group_name", device.name)
|
||||
machine.setMetaDataEntry("group_size", device.clusterSize)
|
||||
digital_factory_string = self.I18N_CATALOG.i18nc("info:name", "Ultimaker Digital Factory")
|
||||
digital_factory_string = self.i18n_catalog.i18nc("info:name", "Ultimaker Digital Factory")
|
||||
digital_factory_link = "<a href='https://digitalfactory.ultimaker.com/'>{}</a>".format(digital_factory_string)
|
||||
removal_warning_string = self.I18N_CATALOG.i18nc(
|
||||
removal_warning_string = self.i18n_catalog.i18nc(
|
||||
"@label ({printer_name} is replaced with the name of the printer",
|
||||
"{printer_name} will be removed until the next account sync. <br> To remove {printer_name} permanently, "
|
||||
"visit {digital_factory_link}"
|
||||
|
@ -469,10 +462,15 @@ class CloudOutputDeviceManager:
|
|||
remove_printers_ids = {self._um_cloud_printers[i].getId() for i in self.reported_device_ids}
|
||||
all_ids = {m.getId() for m in CuraApplication.getInstance().getContainerRegistry().findContainerStacks(type = "machine")}
|
||||
|
||||
question_title = self.I18N_CATALOG.i18nc("@title:window", "Remove printers?")
|
||||
question_content = self.I18N_CATALOG.i18nc("@label", "You are about to remove {} printer(s) from Cura. This action cannot be undone. \nAre you sure you want to continue?".format(len(remove_printers_ids)))
|
||||
question_title = self.i18n_catalog.i18nc("@title:window", "Remove printers?")
|
||||
question_content = self.i18n_catalog.i18ncp(
|
||||
"@label",
|
||||
"You are about to remove {num_printers} printer from Cura. This action cannot be undone.\nAre you sure you want to continue?",
|
||||
"You are about to remove {num_printers} printers from Cura. This action cannot be undone.\nAre you sure you want to continue?",
|
||||
len(remove_printers_ids)
|
||||
).format(num_printers = len(remove_printers_ids))
|
||||
if remove_printers_ids == all_ids:
|
||||
question_content = self.I18N_CATALOG.i18nc("@label", "You are about to remove all printers from Cura. This action cannot be undone. \nAre you sure you want to continue?")
|
||||
question_content = self.i18n_catalog.i18nc("@label", "You are about to remove all printers from Cura. This action cannot be undone.\nAre you sure you want to continue?")
|
||||
result = QMessageBox.question(None, question_title, question_content)
|
||||
if result == QMessageBox.No:
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue