mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-17 03:37:48 -06:00
Make translatePrinter use dict
A translation dictionary makes it much easier to edit the translations. Also this now just translates one printer, instead of a list. Contributes to issue CURA-844.
This commit is contained in:
parent
b5efb2eee8
commit
f13db7de10
2 changed files with 15 additions and 9 deletions
|
@ -85,7 +85,7 @@ class Profile:
|
||||||
if self._weight:
|
if self._weight:
|
||||||
config.set("general", "weight", self._weight)
|
config.set("general", "weight", self._weight)
|
||||||
if self._machine_type_id:
|
if self._machine_type_id:
|
||||||
translated_machine = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translatePrinters([self._machine_type_id])[0]
|
translated_machine = VersionUpgrade21to22.VersionUpgrade21to22.VersionUpgrade21to22.translatePrinter(self._machine_type_id)
|
||||||
config.set("general", "definition", translated_machine)
|
config.set("general", "definition", translated_machine)
|
||||||
else:
|
else:
|
||||||
config.set("general", "definition", "fdmprinter")
|
config.set("general", "definition", "fdmprinter")
|
||||||
|
|
|
@ -9,6 +9,11 @@ from . import MachineInstance # To upgrade machine instances.
|
||||||
from . import Preferences #To upgrade preferences.
|
from . import Preferences #To upgrade preferences.
|
||||||
from . import Profile # To upgrade profiles.
|
from . import Profile # To upgrade profiles.
|
||||||
|
|
||||||
|
## How to translate printer names from the old version to the new.
|
||||||
|
_printer_translation = {
|
||||||
|
"ultimaker2plus": "ultimaker2_plus"
|
||||||
|
}
|
||||||
|
|
||||||
## How to translate profile names from the old version to the new.
|
## How to translate profile names from the old version to the new.
|
||||||
_profile_translation = {
|
_profile_translation = {
|
||||||
"PLA": "generic_pla",
|
"PLA": "generic_pla",
|
||||||
|
@ -16,6 +21,7 @@ _profile_translation = {
|
||||||
"CPE": "generic_cpe"
|
"CPE": "generic_cpe"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## How to translate setting names from the old version to the new.
|
||||||
_setting_name_translation = {
|
_setting_name_translation = {
|
||||||
"speed_support_lines": "speed_support_infill"
|
"speed_support_lines": "speed_support_infill"
|
||||||
}
|
}
|
||||||
|
@ -69,16 +75,16 @@ class VersionUpgrade21to22(VersionUpgrade):
|
||||||
return None
|
return None
|
||||||
return profile.export()
|
return profile.export()
|
||||||
|
|
||||||
## Translates printer names that have changed since the last version.
|
## Translates a printer name that might have changed since the last
|
||||||
|
# version.
|
||||||
#
|
#
|
||||||
# \param printers A list of printer names in the old version.
|
# \param printer A printer name in Cura 2.1.
|
||||||
# \return The same list, but with printer names translated.
|
# \return The name of the corresponding printer in Cura 2.2.
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def translatePrinters(printers):
|
def translatePrinter(printer):
|
||||||
for index, printer in enumerate(printers):
|
if printer in _printer_translation:
|
||||||
if printer == "ultimaker2plus":
|
return _printer_translation[printer]
|
||||||
printers[index] = "ultimaker2_plus"
|
return printer #Doesn't need to be translated.
|
||||||
return printers
|
|
||||||
|
|
||||||
## Translates a built-in profile name that might have changed since the
|
## Translates a built-in profile name that might have changed since the
|
||||||
# last version.
|
# last version.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue