diff --git a/FlatCAMObj.py b/FlatCAMObj.py index c6511f13..9d9d676a 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -200,7 +200,7 @@ class FlatCAMObj(QtCore.QObject): log.debug("on_name_activate() --> Could not remove the old object name from auto-completer model list") self.options["name"] = self.ui.name_entry.get_value() - self.app.inform.emit("[success]Name changed from %s to %s" % (old_name, new_name)) + self.app.inform.emit(_tr("[success]Name changed from %s to %s") % (old_name, new_name)) def on_offset_button_click(self): self.app.report_usage("obj_on_offset_button") @@ -538,7 +538,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): # Show/Hide Advanced Options if self.app.defaults["global_app_level"] == 'b': - self.ui.level.setText('Basic') + self.ui.level.setText(_tr( + 'Basic' + )) self.ui.apertures_table_label.hide() self.ui.aperture_table_visibility_cb.hide() self.ui.milling_type_label.hide() @@ -548,7 +550,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): self.ui.follow_cb.hide() self.ui.padding_area_label.show() else: - self.ui.level.setText('Advanced') + self.ui.level.setText(_tr( + 'Advanced' + )) self.ui.padding_area_label.hide() # set initial state of the aperture table and associated widgets @@ -901,7 +905,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): for g in geo_obj.solid_geometry: if g: - app_obj.inform.emit("[success]Isolation geometry created: %s" % geo_obj.options["name"]) + app_obj.inform.emit(_tr( + "[success]Isolation geometry created: %s" + ) % geo_obj.options["name"]) break else: empty_cnt += 1 @@ -954,7 +960,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): for g in geo_obj.solid_geometry: if g: - app_obj.inform.emit("[success]Isolation geometry created: %s" % geo_obj.options["name"]) + app_obj.inform.emit(_tr( + "[success]Isolation geometry created: %s" + ) % geo_obj.options["name"]) break else: empty_cnt += 1 @@ -1027,7 +1035,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): factor = self.ui.scale_aperture_entry.get_value() except Exception as e: log.debug("FlatCAMGerber.on_scale_aperture_click() --> %s" % str(e)) - self.app.inform.emit("[ERROR_NOTCL] The aperture scale factor value is missing or wrong format.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] The aperture scale factor value is missing or wrong format." + )) return def scale_recursion(geom): @@ -1040,7 +1050,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): return affinity.scale(geom, factor, factor, origin='center') if not self.ui.apertures_table.selectedItems(): - self.app.inform.emit("[WARNING_NOTCL] No aperture to scale. Select at least one aperture and try again.") + self.app.inform.emit(_tr( + "[WARNING_NOTCL] No aperture to scale. Select at least one aperture and try again." + )) return for x in self.ui.apertures_table.selectedItems(): @@ -1058,7 +1070,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): buff_value = self.ui.buffer_aperture_entry.get_value() except Exception as e: log.debug("FlatCAMGerber.on_scale_aperture_click() --> %s" % str(e)) - self.app.inform.emit("[ERROR_NOTCL] The aperture buffer value is missing or wrong format.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] The aperture buffer value is missing or wrong format." + )) return def buffer_recursion(geom): @@ -1071,7 +1085,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber): return geom.buffer(buff_value, join_style=2) if not self.ui.apertures_table.selectedItems(): - self.app.inform.emit("[WARNING_NOTCL] No aperture to scale. Select at least one aperture and try again.") + self.app.inform.emit(_tr( + "[WARNING_NOTCL] No aperture to scale. Select at least one aperture and try again." + )) return for x in self.ui.apertures_table.selectedItems(): @@ -1127,20 +1143,22 @@ class FlatCAMGerber(FlatCAMObj, Gerber): log.debug("on_new_modified_gerber()") - with self.app.proc_container.new("Generating Gerber") as proc: + with self.app.proc_container.new(_tr("Generating Gerber")) as proc: self.app.progress.emit(10) ### Object creation ### ret = self.app.new_object("gerber", name, obj_init, autoselected=False) if ret == 'fail': - self.app.inform.emit('[ERROR_NOTCL] Cretion of Gerber failed.') + self.app.inform.emit(_tr( + '[ERROR_NOTCL] Cretion of Gerber failed.' + )) return self.app.progress.emit(100) # GUI feedback - self.app.inform.emit("[success] Created: " + name) + self.app.inform.emit(_tr("[success] Created: %s") % name) def convert_units(self, units): """ @@ -1260,7 +1278,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber): else: visibility = kwargs['visible'] - with self.app.proc_container.new("Plotting Apertures") as proc: + with self.app.proc_container.new(_tr("Plotting Apertures")) as proc: self.app.progress.emit(30) def job_thread(app_obj): @@ -1714,7 +1732,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): empty_1 = QtWidgets.QTableWidgetItem('') empty_1.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) - label_tot_drill_count = QtWidgets.QTableWidgetItem('Total Drills') + label_tot_drill_count = QtWidgets.QTableWidgetItem(_tr('Total Drills')) tot_drill_count = QtWidgets.QTableWidgetItem('%d' % self.tot_drill_cnt) label_tot_drill_count.setFlags(QtCore.Qt.ItemIsEnabled) tot_drill_count.setFlags(QtCore.Qt.ItemIsEnabled) @@ -1740,7 +1758,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): empty_3 = QtWidgets.QTableWidgetItem('') empty_3.setFlags(~QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) - label_tot_slot_count = QtWidgets.QTableWidgetItem('Total Slots') + label_tot_slot_count = QtWidgets.QTableWidgetItem(_tr('Total Slots')) tot_slot_count = QtWidgets.QTableWidgetItem('%d' % self.tot_slot_cnt) label_tot_slot_count.setFlags(QtCore.Qt.ItemIsEnabled) tot_slot_count.setFlags(QtCore.Qt.ItemIsEnabled) @@ -1874,7 +1892,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): # Show/Hide Advanced Options if self.app.defaults["global_app_level"] == 'b': - self.ui.level.setText('Basic') + self.ui.level.setText(_tr( + 'Basic' + )) self.ui.tools_table.setColumnHidden(4, True) self.ui.estartz_label.hide() @@ -1888,7 +1908,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.ui.feedrate_probe_label.hide() self.ui.feedrate_probe_entry.hide() else: - self.ui.level.setText('Advanced') + self.ui.level.setText(_tr( + 'Advanced' + )) assert isinstance(self.ui, ExcellonObjectUI), \ "Expected a ExcellonObjectUI, got %s" % type(self.ui) @@ -1942,8 +1964,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): self.ui.tools_table.currentItem().setText( self.ui.tools_table.currentItem().text().replace(',', '.')) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, use a number." + )) self.ui.tools_table.currentItem().setText(str(self.tool_offset[dia])) return @@ -2165,12 +2188,16 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): log.debug("Tools 'all' and sorted are: %s" % str(tools)) if len(tools) == 0: - self.app.inform.emit("[ERROR_NOTCL]Please select one or more tools from the list and try again.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Please select one or more tools from the list and try again." + )) return False, "Error: No tools." for tool in tools: if tooldia > self.tools[tool]["C"]: - self.app.inform.emit("[ERROR_NOTCL] Milling tool for DRILLS is larger than hole size. Cancelled.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Milling tool for DRILLS is larger than hole size. Cancelled." + )) return False, "Error: Milling tool is larger than hole." def geo_init(geo_obj, app_obj): @@ -2183,7 +2210,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): # get the tool_table items in a list of row items tool_table_items = self.get_selected_tools_table_items() # insert an information only element in the front - tool_table_items.insert(0, ["Tool_nr", "Diameter", "Drills_Nr", "Slots_Nr"]) + tool_table_items.insert(0, [_tr("Tool_nr"), _tr("Diameter"), _tr("Drills_Nr"), _tr("Slots_Nr")]) geo_obj.options['Tools_in_use'] = tool_table_items geo_obj.options['type'] = 'Excellon Geometry' @@ -2252,7 +2279,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): log.debug("Tools 'all' and sorted are: %s" % str(tools)) if len(tools) == 0: - self.app.inform.emit("[ERROR_NOTCL]Please select one or more tools from the list and try again.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Please select one or more tools from the list and try again." + )) return False, "Error: No tools." for tool in tools: @@ -2260,7 +2289,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): adj_toolstable_tooldia = float('%.4f' % float(tooldia)) adj_file_tooldia = float('%.4f' % float(self.tools[tool]["C"])) if adj_toolstable_tooldia > adj_file_tooldia + 0.0001: - self.app.inform.emit("[ERROR_NOTCL] Milling tool for SLOTS is larger than hole size. Cancelled.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Milling tool for SLOTS is larger than hole size. Cancelled." + )) return False, "Error: Milling tool is larger than hole." def geo_init(geo_obj, app_obj): @@ -2273,7 +2304,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): # get the tool_table items in a list of row items tool_table_items = self.get_selected_tools_table_items() # insert an information only element in the front - tool_table_items.insert(0, ["Tool_nr", "Diameter", "Drills_Nr", "Slots_Nr"]) + tool_table_items.insert(0, [_tr("Tool_nr"), _tr("Diameter"), _tr("Drills_Nr"), _tr("Slots_Nr")]) geo_obj.options['Tools_in_use'] = tool_table_items geo_obj.options['type'] = 'Excellon Geometry' @@ -2363,7 +2394,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): if self.ui.tools_table.rowCount() == 3: tools.append(self.ui.tools_table.item(0, 0).text()) else: - self.app.inform.emit("[ERROR_NOTCL]Please select one or more tools from the list and try again.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Please select one or more tools from the list and try again." + )) return xmin = self.options['xmin'] @@ -2382,7 +2415,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): # get the tool_table items in a list of row items tool_table_items = self.get_selected_tools_table_items() # insert an information only element in the front - tool_table_items.insert(0, ["Tool_nr", "Diameter", "Drills_Nr", "Slots_Nr"]) + tool_table_items.insert(0, [_tr("Tool_nr"), _tr("Diameter"), _tr("Drills_Nr"), _tr("Slots_Nr")]) ### Add properties to the object @@ -2419,7 +2452,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]' + )) try: job_obj.feedrate_probe = float(self.options["feedrate_probe"]) @@ -2429,8 +2464,11 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' - 'or self.options["feedrate_probe"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' + 'or self.options["feedrate_probe"]' + ) + ) # There could be more than one drill size... # job_obj.tooldia = # TODO: duplicate variable! @@ -2459,7 +2497,7 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): # To be run in separate thread def job_thread(app_obj): - with self.app.proc_container.new("Generating CNC Code"): + with self.app.proc_container.new(_tr("Generating CNC Code")): app_obj.new_object("cncjob", job_name, job_init) app_obj.progress.emit(100) @@ -2484,8 +2522,10 @@ class FlatCAMExcellon(FlatCAMObj, Excellon): else: coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")] if len(coords_xy) < 2: - self.app.inform.emit("[ERROR]The Toolchange X,Y field in Edit -> Preferences has to be " - "in the format (x, y) \nbut now there is only one value, not two. ") + self.app.inform.emit(_tr( + "[ERROR]The Toolchange X,Y field in Edit -> Preferences has to be " + "in the format (x, y) \nbut now there is only one value, not two. " + )) return 'fail' coords_xy[0] *= factor coords_xy[1] *= factor @@ -2830,8 +2870,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): # those elements are the ones used for generating GCode self.sel_tools = {} - self.offset_item_options = ["Path", "In", "Out", "Custom"] - self.type_item_options = ["Iso", "Rough", "Finish"] + self.offset_item_options = [_tr("Path"), _tr("In"), _tr("Out"), _tr("Custom")] + self.type_item_options = [_tr("Iso"), _tr("Rough"), _tr("Finish")] self.tool_type_item_options = ["C1", "C2", "C3", "C4", "B", "V"] # flag to store if the V-Shape tool is selected in self.ui.geo_tools_table @@ -3072,9 +3112,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.tools.update({ self.tooluid: { 'tooldia': float(self.options["cnctooldia"]), - 'offset': 'Path', + 'offset': _tr('Path'), 'offset_value': 0.0, - 'type': 'Rough', + 'type': _tr('Rough'), 'tool_type': 'C1', 'data': self.default_data, 'solid_geometry': self.solid_geometry @@ -3109,13 +3149,15 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.geo_tools_table.setupContextMenu() self.ui.geo_tools_table.addContextMenu( - "Copy", self.on_tool_copy, icon=QtGui.QIcon("share/copy16.png")) + _tr("Copy"), self.on_tool_copy, icon=QtGui.QIcon("share/copy16.png")) self.ui.geo_tools_table.addContextMenu( - "Delete", lambda: self.on_tool_delete(all=None), icon=QtGui.QIcon("share/delete32.png")) + _tr("Delete"), lambda: self.on_tool_delete(all=None), icon=QtGui.QIcon("share/delete32.png")) # Show/Hide Advanced Options if self.app.defaults["global_app_level"] == 'b': - self.ui.level.setText('Basic') + self.ui.level.setText(_tr( + 'Basic' + )) self.ui.geo_tools_table.setColumnHidden(2, True) self.ui.geo_tools_table.setColumnHidden(3, True) @@ -3135,7 +3177,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.feedrate_probe_label.hide() self.ui.feedrate_probe_entry.hide() else: - self.ui.level.setText('Advanced') + self.ui.level.setText(_tr( + 'Advanced' + )) self.ui.plot_cb.stateChanged.connect(self.on_plot_cb_click) self.ui.generate_cnc_button.clicked.connect(self.on_generatecnc_button_click) @@ -3149,7 +3193,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): tool_offset = self.ui.geo_tools_table.cellWidget(current_row, 2) if tool_offset is not None: tool_offset_txt = tool_offset.currentText() - if tool_offset_txt == 'Custom': + if tool_offset_txt == _tr('Custom'): self.ui.tool_offset_entry.show() self.ui.tool_offset_lbl.show() else: @@ -3183,8 +3227,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.tool_offset_entry.get_value().replace(',', '.') ) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + ) + ) return def ui_connect(self): @@ -3321,7 +3368,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): if tooldia is None: self.build_ui() - self.app.inform.emit("[ERROR_NOTCL] Please enter the desired tool diameter in Float format.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Please enter the desired tool diameter in Float format." + )) return # construct a list of all 'tooluid' in the self.tools @@ -3348,9 +3397,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.tools.update({ self.tooluid: { 'tooldia': tooldia, - 'offset': 'Path', + 'offset': _tr('Path'), 'offset_value': 0.0, - 'type': 'Rough', + 'type': _tr('Rough'), 'tool_type': 'C1', 'data': copy.deepcopy(self.default_data), 'solid_geometry': self.solid_geometry @@ -3394,10 +3443,14 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ser_attrs.append('tools') if change_message is False: - self.app.inform.emit("[success] Tool added in Tool Table.") + self.app.inform.emit(_tr( + "[success] Tool added in Tool Table." + )) else: change_message = False - self.app.inform.emit("[ERROR_NOTCL]Default Tool added. Wrong value format entered.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Default Tool added. Wrong value format entered." + )) self.build_ui() def on_tool_copy(self, all=None): @@ -3425,7 +3478,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): max_uid += 1 self.tools[int(max_uid)] = copy.deepcopy(self.tools[tooluid_copy]) except AttributeError: - self.app.inform.emit("[WARNING_NOTCL]Failed. Select a tool to copy.") + self.app.inform.emit(_tr( + "[WARNING_NOTCL]Failed. Select a tool to copy." + )) self.build_ui() return except Exception as e: @@ -3433,7 +3488,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): # deselect the table # self.ui.geo_tools_table.clearSelection() else: - self.app.inform.emit("[WARNING_NOTCL]Failed. Select a tool to copy.") + self.app.inform.emit(_tr( + "[WARNING_NOTCL]Failed. Select a tool to copy." + )) self.build_ui() return else: @@ -3460,7 +3517,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ser_attrs.append('tools') self.build_ui() - self.app.inform.emit("[success] Tool was copied in Tool Table.") + self.app.inform.emit(_tr( + "[success] Tool was copied in Tool Table." + )) def on_tool_edit(self, current_item): @@ -3474,8 +3533,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: d = float(self.ui.geo_tools_table.item(current_row, 1).text().replace(',', '.')) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return tool_dia = float('%.4f' % d) @@ -3489,7 +3550,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): except: pass - self.app.inform.emit("[success] Tool was edited in Tool Table.") + self.app.inform.emit(_tr( + "[success] Tool was edited in Tool Table." + )) self.build_ui() def on_tool_delete(self, all=None): @@ -3518,7 +3581,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.tools = copy.deepcopy(temp_tools) temp_tools.clear() except AttributeError: - self.app.inform.emit("[WARNING_NOTCL]Failed. Select a tool to delete.") + self.app.inform.emit(_tr( + "[WARNING_NOTCL]Failed. Select a tool to delete." + )) self.build_ui() return except Exception as e: @@ -3526,7 +3591,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): # deselect the table # self.ui.geo_tools_table.clearSelection() else: - self.app.inform.emit("[WARNING_NOTCL]Failed. Select a tool to delete.") + self.app.inform.emit(_tr( + "[WARNING_NOTCL]Failed. Select a tool to delete." + )) self.build_ui() return else: @@ -3548,7 +3615,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ser_attrs.append('tools') self.build_ui() - self.app.inform.emit("[success] Tool was deleted in Tool Table.") + self.app.inform.emit(_tr( + "[success] Tool was deleted in Tool Table." + )) obj_active = self.app.collection.get_active() # if the object was MultiGeo and now it has no tool at all (therefore no geometry) @@ -3651,8 +3720,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: vdia = float(self.ui.tipdia_entry.get_value().replace(',', '.')) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return try: @@ -3662,8 +3733,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: half_vangle = float(self.ui.tipangle_entry.get_value().replace(',', '.')) / 2 except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return @@ -3693,7 +3766,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): cb_txt = cw.currentText() if cw_col == 2: tooluid_value['offset'] = cb_txt - if cb_txt == 'Custom': + if cb_txt == _tr('Custom'): self.ui.tool_offset_entry.show() self.ui.tool_offset_lbl.show() else: @@ -3704,8 +3777,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): elif cw_col == 3: # force toolpath type as 'Iso' if the tool type is V-Shape if self.ui.geo_tools_table.cellWidget(cw_row, 4).currentText() == 'V': - tooluid_value['type'] = 'Iso' - idx = self.ui.geo_tools_table.cellWidget(cw_row, 3).findText('Iso') + tooluid_value['type'] = _tr('Iso') + idx = self.ui.geo_tools_table.cellWidget(cw_row, 3).findText(_tr('Iso')) self.ui.geo_tools_table.cellWidget(cw_row, 3).setCurrentIndex(idx) else: tooluid_value['type'] = cb_txt @@ -3714,7 +3787,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): # if the tool_type selected is V-Shape then autoselect the toolpath type as Iso if cb_txt == 'V': - idx = self.ui.geo_tools_table.cellWidget(cw_row, 3).findText('Iso') + idx = self.ui.geo_tools_table.cellWidget(cw_row, 3).findText(_tr('Iso')) self.ui.geo_tools_table.cellWidget(cw_row, 3).setCurrentIndex(idx) self.ui_update_v_shape(tool_type_txt=self.ui.geo_tools_table.cellWidget(cw_row, 4).currentText()) @@ -3777,8 +3850,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): offset_value_item = float(self.ui.tool_offset_entry.get_value().replace(',', '.') ) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return # this new dict will hold the actual useful data, another dict that is the value of key 'data' @@ -3954,8 +4029,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: if self.special_group: - self.app.inform.emit("[WARNING_NOTCL]This Geometry can't be processed because it is %s geometry." % - str(self.special_group)) + self.app.inform.emit(_tr( + "[WARNING_NOTCL]This Geometry can't be processed because it is %s geometry." + ) % str(self.special_group)) return except AttributeError: pass @@ -3970,8 +4046,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: tooldia = float(self.ui.geo_tools_table.item(x.row(), 1).text().replace(',', '.')) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong Tool Dia value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong Tool Dia value format entered, " + "use a number." + )) return tooluid = int(self.ui.geo_tools_table.item(x.row(), 5).text()) @@ -3995,7 +4073,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.ui.geo_tools_table.clearSelection() else: - self.app.inform.emit("[ERROR_NOTCL] Failed. No tool selected in the tool table ...") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Failed. No tool selected in the tool table ..." + )) def mtool_gen_cncjob(self, segx=None, segy=None, use_thread=True): """ @@ -4031,8 +4111,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): ymax = self.options['ymax'] except Exception as e: log.debug("FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s\n" % str(e)) - msg = "[ERROR] An internal error has ocurred. See shell.\n" - msg += 'FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s' % str(e) + msg = _tr("[ERROR] An internal error has ocurred. See shell.\n") + msg += _tr('FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s') % str(e) msg += traceback.format_exc() self.app.inform.emit(msg) return @@ -4066,7 +4146,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]' + )) try: job_obj.feedrate_probe = float(self.options["feedrate_probe"]) @@ -4076,8 +4158,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' - 'or self.options["feedrate_probe"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' + 'or self.options["feedrate_probe"]' + )) for tooluid_key in self.sel_tools: tool_cnt += 1 @@ -4174,15 +4258,19 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): offset_value = float(self.ui.tool_offset_entry.get_value().replace(',', '.') ) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return if offset_value: tool_offset = float(offset_value) else: self.app.inform.emit( - "[WARNING] Tool Offset is selected in Tool Table but no value is provided.\n" - "Add a Tool Offset or change the Offset Type." + _tr( + "[WARNING] Tool Offset is selected in Tool Table but no value is provided.\n" + "Add a Tool Offset or change the Offset Type." + ) ) return dia_cnc_dict.update({ @@ -4269,7 +4357,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]' + )) try: job_obj.feedrate_probe = float(self.options["feedrate_probe"]) @@ -4279,8 +4369,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' - 'or self.options["feedrate_probe"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' + 'or self.options["feedrate_probe"]' + )) # make sure that trying to make a CNCJob from an empty file is not creating an app crash if not self.solid_geometry: @@ -4289,7 +4381,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): if self.tools[tooluid_key]['solid_geometry'] is None: a += 1 if a == len(self.tools): - self.app.inform.emit('[ERROR_NOTCL]Cancelled. Empty file, it has no geometry...') + self.app.inform.emit(_tr( + '[ERROR_NOTCL]Cancelled. Empty file, it has no geometry...' + )) return 'fail' for tooluid_key in self.sel_tools: @@ -4397,15 +4491,19 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): offset_value = float(self.ui.tool_offset_entry.get_value().replace(',', '.') ) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return if offset_value: tool_offset = float(offset_value) else: self.app.inform.emit( - "[WARNING] Tool Offset is selected in Tool Table but no value is provided.\n" - "Add a Tool Offset or change the Offset Type." + _tr( + "[WARNING] Tool Offset is selected in Tool Table but no value is provided.\n" + "Add a Tool Offset or change the Offset Type." + ) ) return dia_cnc_dict.update({ @@ -4462,12 +4560,12 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): # separate solid_geometry in the self.tools dictionary def job_thread(app_obj): if self.solid_geometry: - with self.app.proc_container.new("Generating CNC Code"): + with self.app.proc_container.new(_tr("Generating CNC Code")): if app_obj.new_object("cncjob", outname, job_init_single_geometry) != 'fail': app_obj.inform.emit("[success]CNCjob created: %s" % outname) app_obj.progress.emit(100) else: - with self.app.proc_container.new("Generating CNC Code"): + with self.app.proc_container.new(_tr("Generating CNC Code")): if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail': app_obj.inform.emit("[success]CNCjob created: %s" % outname) app_obj.progress.emit(100) @@ -4574,7 +4672,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]' + )) try: job_obj.feedrate_probe = float(self.options["feedrate_probe"]) @@ -4584,8 +4684,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.')) except ValueError: self.app.inform.emit( - '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' - 'or self.options["feedrate_probe"]') + _tr( + '[ERROR_NOTCL]Wrong value format for self.defaults["feedrate_probe"] ' + 'or self.options["feedrate_probe"]' + )) # TODO: The tolerance should not be hard coded. Just for testing. job_obj.generate_from_geometry_2(self, tooldia=tooldia, offset=offset, tolerance=0.0005, @@ -4609,7 +4711,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): if use_thread: # To be run in separate thread def job_thread(app_obj): - with self.app.proc_container.new("Generating CNC Code"): + with self.app.proc_container.new(_tr("Generating CNC Code")): app_obj.new_object("cncjob", outname, job_init) app_obj.inform.emit("[success]CNCjob created: %s" % outname) app_obj.progress.emit(100) @@ -4641,7 +4743,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: xfactor = float(xfactor) except: - self.app.inform.emit("[ERROR_NOTCL] Scale factor has to be a number: integer or float.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Scale factor has to be a number: integer or float.")) return if yfactor is None: @@ -4650,7 +4753,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: yfactor = float(yfactor) except: - self.app.inform.emit("[ERROR_NOTCL] Scale factor has to be a number: integer or float.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Scale factor has to be a number: integer or float." + )) return if point is None: @@ -4686,7 +4791,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): else: self.solid_geometry=scale_recursion(self.solid_geometry) - self.app.inform.emit("[success]Geometry Scale done.") + self.app.inform.emit(_tr( + "[success]Geometry Scale done." + )) def offset(self, vect): """ @@ -4701,8 +4808,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): try: dx, dy = vect except TypeError: - self.app.inform.emit("[ERROR_NOTCL]An (x,y) pair of values are needed. " - "Probable you entered only one value in the Offset field.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]An (x,y) pair of values are needed. " + "Probable you entered only one value in the Offset field." + )) return def translate_recursion(geom): @@ -4719,7 +4828,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): self.tools[tool]['solid_geometry'] = translate_recursion(self.tools[tool]['solid_geometry']) else: self.solid_geometry=translate_recursion(self.solid_geometry) - self.app.inform.emit("[success]Geometry Offset done.") + self.app.inform.emit(_tr( + "[success]Geometry Offset done." + )) def convert_units(self, units): self.ui_disconnect() @@ -4745,8 +4856,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): else: coords_xy = [float(eval(coord)) for coord in self.app.defaults["geometry_toolchangexy"].split(",")] if len(coords_xy) < 2: - self.app.inform.emit("[ERROR]The Toolchange X,Y field in Edit -> Preferences has to be " - "in the format (x, y) \nbut now there is only one value, not two. ") + self.app.inform.emit(_tr( + "[ERROR]The Toolchange X,Y field in Edit -> Preferences has to be " + "in the format (x, y) \nbut now there is only one value, not two. " + )) return 'fail' coords_xy[0] *= factor coords_xy[1] *= factor @@ -4784,8 +4897,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): custom_offset = float(self.ui.tool_offset_entry.get_value().replace(',', '.') ) except ValueError: - self.app.inform.emit("[ERROR_NOTCL]Wrong value format entered, " - "use a number.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL]Wrong value format entered, " + "use a number." + )) return except TypeError: pass @@ -5187,11 +5302,15 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): # Show/Hide Advanced Options if self.app.defaults["global_app_level"] == 'b': - self.ui.level.setText('Basic') + self.ui.level.setText(_tr( + 'Basic' + )) self.ui.cnc_frame.hide() else: - self.ui.level.setText('Advanced') + self.ui.level.setText(_tr( + 'Advanced' + )) self.ui.cnc_frame.show() self.ui.updateplot_button.clicked.connect(self.on_updateplot_button_click) @@ -5257,12 +5376,13 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): filter=_filter_ ) except TypeError: - filename, _ = QtWidgets.QFileDialog.getSaveFileName(caption="Export Machine Code ...", filter=_filter_) + filename, _ = QtWidgets.QFileDialog.getSaveFileName(caption=_tr("Export Machine Code ..."), filter=_filter_) filename = str(filename) if filename == '': - self.app.inform.emit("[WARNING_NOTCL]Export Machine Code cancelled ...") + self.app.inform.emit(_tr( + "[WARNING_NOTCL]Export Machine Code cancelled ...")) return preamble = str(self.ui.prepend_text.get_value()) @@ -5273,7 +5393,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): return self.app.file_saved.emit("gcode", filename) - self.app.inform.emit("[success] Machine Code file saved to: %s" % filename) + self.app.inform.emit(_tr("[success] Machine Code file saved to: %s") % filename) def on_modifygcode_button_click(self, *args): preamble = str(self.ui.prepend_text.get_value()) @@ -5285,7 +5405,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): self.app.gcode_edited = gc # add the tab if it was closed - self.app.ui.plot_tab_area.addTab(self.app.ui.cncjob_tab, "Code Editor") + self.app.ui.plot_tab_area.addTab(self.app.ui.cncjob_tab, _tr("Code Editor")) # delete the absolute and relative position and messages in the infobar self.app.ui.position_label.setText("") @@ -5304,7 +5424,7 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): self.app.ui.code_editor.append(proc_line) except Exception as e: log.debug('FlatCAMCNNJob.on_modifygcode_button_click() -->%s' % str(e)) - self.app.inform.emit('[ERROR]FlatCAMCNNJob.on_modifygcode_button_click() -->%s' % str(e)) + self.app.inform.emit(_tr('[ERROR]FlatCAMCNNJob.on_modifygcode_button_click() -->%s') % str(e)) return self.app.ui.code_editor.moveCursor(QtGui.QTextCursor.Start) @@ -5410,8 +5530,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): try: if self.special_group: - self.app.inform.emit("[WARNING_NOTCL]This CNCJob object can't be processed because " - "it is a %s CNCJob object." % str(self.special_group)) + self.app.inform.emit(_tr("[WARNING_NOTCL]This CNCJob object can't be processed because " + "it is a %s CNCJob object.") % str(self.special_group)) return 'fail' except AttributeError: pass @@ -5462,7 +5582,9 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): # if it did not find 'G20' and it did not find 'G21' then there is an error and return if g_idx == -1: - self.app.inform.emit("[ERROR_NOTCL] G-code does not have a units code: either G20 or G21") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] G-code does not have a units code: either G20 or G21" + )) return g = gcode[:g_idx] + preamble + '\n' + gcode[g_idx:] + postamble @@ -5473,12 +5595,16 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): if 'M6' in g: m6_code = self.parse_custom_toolchange_code(self.ui.toolchange_text.get_value()) if m6_code is None or m6_code == '': - self.app.inform.emit("[ERROR_NOTCL] Cancelled. The Toolchange Custom code is enabled " - "but it's empty.") + self.app.inform.emit(_tr( + "[ERROR_NOTCL] Cancelled. The Toolchange Custom code is enabled " + "but it's empty." + )) return 'fail' g = g.replace('M6', m6_code) - self.app.inform.emit("[success] Toolchange G-code was replaced by a custom code.") + self.app.inform.emit(_tr( + "[success] Toolchange G-code was replaced by a custom code." + )) # lines = StringIO(self.gcode) lines = StringIO(g) @@ -5491,7 +5617,9 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): f.write(line) except FileNotFoundError: - self.app.inform.emit("[WARNING_NOTCL] No such file or directory") + self.app.inform.emit(_tr( + "[WARNING_NOTCL] No such file or directory" + )) return elif to_file is False: # Just for adding it to the recent files list. @@ -5509,7 +5637,9 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): if self.ui.toolchange_cb.get_value(): self.ui.toolchange_cb.set_value(False) self.app.inform.emit( - "[WARNING_NOTCL] The used postprocessor file has to have in it's name: 'toolchange_custom'") + _tr( + "[WARNING_NOTCL] The used postprocessor file has to have in it's name: 'toolchange_custom'" + )) except KeyError: try: for key in self.cnc_tools: @@ -5519,11 +5649,15 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob): if self.ui.toolchange_cb.get_value(): self.ui.toolchange_cb.set_value(False) self.app.inform.emit( - "[WARNING_NOTCL] The used postprocessor file has to have in it's name: " - "'toolchange_custom'") + _tr( + "[WARNING_NOTCL] The used postprocessor file has to have in it's name: " + "'toolchange_custom'" + )) except KeyError: self.app.inform.emit( - "[ERROR] There is no postprocessor file.") + _tr( + "[ERROR] There is no postprocessor file." + )) def get_gcode(self, preamble='', postamble=''): #we need this to be able get_gcode separatelly for shell command export_gcode diff --git a/ObjectUI.py b/ObjectUI.py index 88fd8e90..5c36ab9b 100644 --- a/ObjectUI.py +++ b/ObjectUI.py @@ -23,7 +23,7 @@ class ObjectUI(QtWidgets.QWidget): put UI elements in ObjectUI.custom_box (QtWidgets.QLayout). """ - def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object', parent=None): + def __init__(self, icon_file='share/flatcam_icon32.png', title=_tr('FlatCAM Object'), parent=None): QtWidgets.QWidget.__init__(self, parent=parent) layout = QtWidgets.QVBoxLayout() @@ -40,19 +40,21 @@ class ObjectUI(QtWidgets.QWidget): self.title_box.addWidget(self.icon, stretch=0) ## Title label - self.title_label = QtWidgets.QLabel("" + title + "") + self.title_label = QtWidgets.QLabel("%s" % title) self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.title_box.addWidget(self.title_label, stretch=1) ## App Level label self.level = QtWidgets.QLabel("") self.level.setToolTip( - "BASIC is suitable for a beginner. Many parameters\n" - "are hidden from the user in this mode.\n" - "ADVANCED mode will make available all parameters.\n\n" - "To change the application LEVEL, go to:\n" - "Edit -> Preferences -> General and check:\n" - "'APP. LEVEL' radio button." + _tr( + "BASIC is suitable for a beginner. Many parameters\n" + "are hidden from the user in this mode.\n" + "ADVANCED mode will make available all parameters.\n\n" + "To change the application LEVEL, go to:\n" + "Edit -> Preferences -> General and check:\n" + "'APP. LEVEL' radio button." + ) ) self.level.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.title_box.addWidget(self.level) @@ -67,9 +69,9 @@ class ObjectUI(QtWidgets.QWidget): ########################### #### Scale #### - self.scale_label = QtWidgets.QLabel('Scale:') + self.scale_label = QtWidgets.QLabel(_tr('Scale:')) self.scale_label.setToolTip( - "Change the size of the object." + _tr("Change the size of the object.") ) layout.addWidget(self.scale_label) @@ -77,10 +79,10 @@ class ObjectUI(QtWidgets.QWidget): layout.addLayout(self.scale_grid) # Factor - faclabel = QtWidgets.QLabel('Factor:') + faclabel = QtWidgets.QLabel(_tr('Factor:')) faclabel.setToolTip( - "Factor by which to multiply\n" - "geometric features of this object." + _tr("Factor by which to multiply\n" + "geometric features of this object.") ) self.scale_grid.addWidget(faclabel, 0, 0) self.scale_entry = FloatEntry2() @@ -88,36 +90,36 @@ class ObjectUI(QtWidgets.QWidget): self.scale_grid.addWidget(self.scale_entry, 0, 1) # GO Button - self.scale_button = QtWidgets.QPushButton('Scale') + self.scale_button = QtWidgets.QPushButton(_tr('Scale')) self.scale_button.setToolTip( - "Perform scaling operation." + _tr("Perform scaling operation.") ) self.scale_button.setFixedWidth(40) self.scale_grid.addWidget(self.scale_button, 0, 2) #### Offset #### - self.offset_label = QtWidgets.QLabel('Offset:') + self.offset_label = QtWidgets.QLabel(_tr('Offset:')) self.offset_label.setToolTip( - "Change the position of this object." + _tr("Change the position of this object.") ) layout.addWidget(self.offset_label) self.offset_grid = QtWidgets.QGridLayout() layout.addLayout(self.offset_grid) - self.offset_vectorlabel = QtWidgets.QLabel('Vector:') + self.offset_vectorlabel = QtWidgets.QLabel(_tr('Vector:')) self.offset_vectorlabel.setToolTip( - "Amount by which to move the object\n" - "in the x and y axes in (x, y) format." + _tr("Amount by which to move the object\n" + "in the x and y axes in (x, y) format.") ) self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0) self.offsetvector_entry = EvalEntry2() self.offsetvector_entry.setText("(0.0, 0.0)") self.offset_grid.addWidget(self.offsetvector_entry, 0, 1) - self.offset_button = QtWidgets.QPushButton('Offset') + self.offset_button = QtWidgets.QPushButton(_tr('Offset')) self.offset_button.setToolTip( - "Perform the offset operation." + _tr("Perform the offset operation.") ) self.offset_button.setFixedWidth(40) self.offset_grid.addWidget(self.offset_button, 0, 2) @@ -131,38 +133,38 @@ class GerberObjectUI(ObjectUI): """ def __init__(self, parent=None): - ObjectUI.__init__(self, title='Gerber Object', parent=parent) + ObjectUI.__init__(self, title=_tr('Gerber Object'), parent=parent) # Plot options grid0 = QtWidgets.QGridLayout() grid0.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.custom_box.addLayout(grid0) - self.plot_options_label = QtWidgets.QLabel("Plot Options:") + self.plot_options_label = QtWidgets.QLabel(_tr("Plot Options:")) self.plot_options_label.setFixedWidth(90) grid0.addWidget(self.plot_options_label, 0, 0) # Solid CB - self.solid_cb = FCCheckBox(label='Solid ') + self.solid_cb = FCCheckBox(label=_tr('Solid ')) self.solid_cb.setToolTip( - "Solid color polygons." + _tr("Solid color polygons.") ) self.solid_cb.setFixedWidth(50) grid0.addWidget(self.solid_cb, 0, 1) # Multicolored CB - self.multicolored_cb = FCCheckBox(label='M-Color ') + self.multicolored_cb = FCCheckBox(label=_tr('M-Color ')) self.multicolored_cb.setToolTip( - "Draw polygons in different colors." + _tr("Draw polygons in different colors.") ) self.multicolored_cb.setFixedWidth(55) grid0.addWidget(self.multicolored_cb, 0, 2) # Plot CB - self.plot_cb = FCCheckBox('Plot') + self.plot_cb = FCCheckBox(_tr('Plot')) self.plot_cb.setToolTip( - "Plot (show) this object." + _tr("Plot (show) this object.") ) self.plot_cb.setFixedWidth(55) grid0.addWidget(self.plot_cb, 0, 3) @@ -170,7 +172,7 @@ class GerberObjectUI(ObjectUI): ## Object name self.name_hlay = QtWidgets.QHBoxLayout() self.custom_box.addLayout(self.name_hlay) - name_label = QtWidgets.QLabel("Name:") + name_label = QtWidgets.QLabel(_tr("Name:")) self.name_entry = FCEntry() self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus) self.name_hlay.addWidget(name_label) @@ -180,9 +182,9 @@ class GerberObjectUI(ObjectUI): self.custom_box.addLayout(hlay_plot) #### Gerber Apertures #### - self.apertures_table_label = QtWidgets.QLabel('Apertures:') + self.apertures_table_label = QtWidgets.QLabel(_tr('Apertures:')) self.apertures_table_label.setToolTip( - "Apertures Table for the Gerber Object." + _tr("Apertures Table for the Gerber Object.") ) self.apertures_table_label.setFixedWidth(90) @@ -191,9 +193,9 @@ class GerberObjectUI(ObjectUI): # Aperture Table Visibility CB self.aperture_table_visibility_cb = FCCheckBox() self.aperture_table_visibility_cb.setToolTip( - "Toggle the display of the Gerber Apertures Table.\n" + _tr("Toggle the display of the Gerber Apertures Table.\n" "When unchecked, it will delete all mark shapes\n" - "that are drawn on canvas." + "that are drawn on canvas.") ) # self.aperture_table_visibility_cb.setLayoutDirection(QtCore.Qt.RightToLeft) @@ -202,11 +204,11 @@ class GerberObjectUI(ObjectUI): hlay_plot.addStretch() # Aperture Mark all CB - self.mark_all_cb = FCCheckBox('Mark All') + self.mark_all_cb = FCCheckBox(_tr('Mark All')) self.mark_all_cb.setToolTip( - "When checked it will display all the apertures.\n" + _tr("When checked it will display all the apertures.\n" "When unchecked, it will delete all mark shapes\n" - "that are drawn on canvas." + "that are drawn on canvas.") ) self.mark_all_cb.setLayoutDirection(QtCore.Qt.RightToLeft) @@ -216,23 +218,23 @@ class GerberObjectUI(ObjectUI): self.custom_box.addWidget(self.apertures_table) self.apertures_table.setColumnCount(6) - self.apertures_table.setHorizontalHeaderLabels(['#', 'Code', 'Type', 'Size', 'Dim', 'M']) + self.apertures_table.setHorizontalHeaderLabels(['#', _tr('Code'), _tr('Type'), _tr('Size'), _tr('Dim'), 'M']) self.apertures_table.setSortingEnabled(False) self.apertures_table.horizontalHeaderItem(0).setToolTip( - "Index") + _tr("Index")) self.apertures_table.horizontalHeaderItem(1).setToolTip( - "Aperture Code") + _tr("Aperture Code")) self.apertures_table.horizontalHeaderItem(2).setToolTip( - "Type of aperture: circular, rectangle, macros etc") + _tr("Type of aperture: circular, rectangle, macros etc")) self.apertures_table.horizontalHeaderItem(4).setToolTip( - "Aperture Size:") + _tr("Aperture Size:")) self.apertures_table.horizontalHeaderItem(4).setToolTip( - "Aperture Dimensions:\n" + _tr("Aperture Dimensions:\n" " - (width, height) for R, O type.\n" - " - (dia, nVertices) for P type") + " - (dia, nVertices) for P type")) self.apertures_table.horizontalHeaderItem(5).setToolTip( - "Mark the aperture instances on canvas.") + _tr("Mark the aperture instances on canvas.")) # self.apertures_table.setColumnHidden(5, True) #### Aperture Scale #### @@ -240,11 +242,11 @@ class GerberObjectUI(ObjectUI): self.custom_box.addLayout(self.transform_aperture_grid) # Scale Aperture Factor - self.scale_aperture_label = QtWidgets.QLabel('Scale Factor:') + self.scale_aperture_label = QtWidgets.QLabel(_tr('Scale Factor:')) self.scale_aperture_label.setToolTip( - "Change the size of the selected apertures.\n" + _tr("Change the size of the selected apertures.\n" "Factor by which to multiply\n" - "geometric features of this object." + "geometric features of this object.") ) self.scale_aperture_label.setFixedWidth(90) self.transform_aperture_grid.addWidget(self.scale_aperture_label, 0, 0) @@ -253,19 +255,19 @@ class GerberObjectUI(ObjectUI): self.transform_aperture_grid.addWidget(self.scale_aperture_entry, 0, 1) # Scale Button - self.scale_aperture_button = QtWidgets.QPushButton('Scale') + self.scale_aperture_button = QtWidgets.QPushButton(_tr('Scale')) self.scale_aperture_button.setToolTip( - "Perform scaling operation on the selected apertures." + _tr("Perform scaling operation on the selected apertures.") ) self.scale_aperture_button.setFixedWidth(50) self.transform_aperture_grid.addWidget(self.scale_aperture_button, 0, 2) # Buffer Aperture Factor - self.buffer_aperture_label = QtWidgets.QLabel('Buffer Factor:') + self.buffer_aperture_label = QtWidgets.QLabel(_tr('Buffer Factor:')) self.buffer_aperture_label.setToolTip( - "Change the size of the selected apertures.\n" + _tr("Change the size of the selected apertures.\n" "Factor by which to expand/shrink\n" - "geometric features of this object." + "geometric features of this object.") ) self.buffer_aperture_label.setFixedWidth(90) self.transform_aperture_grid.addWidget(self.buffer_aperture_label, 1, 0) @@ -274,9 +276,9 @@ class GerberObjectUI(ObjectUI): self.transform_aperture_grid.addWidget(self.buffer_aperture_entry, 1, 1) # Buffer Button - self.buffer_aperture_button = QtWidgets.QPushButton('Buffer') + self.buffer_aperture_button = QtWidgets.QPushButton(_tr('Buffer')) self.buffer_aperture_button.setToolTip( - "Perform buffer operation on the selected apertures." + _tr("Perform buffer operation on the selected apertures.") ) self.buffer_aperture_button.setFixedWidth(50) self.transform_aperture_grid.addWidget(self.buffer_aperture_button, 1, 2) @@ -284,18 +286,18 @@ class GerberObjectUI(ObjectUI): new_hlay = QtWidgets.QHBoxLayout() self.custom_box.addLayout(new_hlay) - self.new_grb_label = QtWidgets.QLabel("Generate new Gerber Object:") + self.new_grb_label = QtWidgets.QLabel(_tr("Generate new Gerber Object:")) self.new_grb_label.setToolTip( - "Will generate a new Gerber object from the changed apertures." + _tr("Will generate a new Gerber object from the changed apertures.") ) new_hlay.addWidget(self.new_grb_label) new_hlay.addStretch() - self.new_grb_button = FCButton('Go') + self.new_grb_button = FCButton(_tr('Go')) self.new_grb_button.setToolTip( - "Will generate a new Gerber object from the changed apertures.\n" - "This new object can then be isolated etc.") + _tr("Will generate a new Gerber object from the changed apertures.\n" + "This new object can then be isolated etc.")) self.new_grb_button.setFixedWidth(50) new_hlay.addWidget(self.new_grb_button) @@ -310,43 +312,43 @@ class GerberObjectUI(ObjectUI): self.buffer_aperture_button.setVisible(False) # Isolation Routing - self.isolation_routing_label = QtWidgets.QLabel("Isolation Routing:") + self.isolation_routing_label = QtWidgets.QLabel(_tr("Isolation Routing:")) self.isolation_routing_label.setToolTip( - "Create a Geometry object with\n" - "toolpaths to cut outside polygons." + _tr("Create a Geometry object with\n" + "toolpaths to cut outside polygons.") ) self.custom_box.addWidget(self.isolation_routing_label) grid1 = QtWidgets.QGridLayout() self.custom_box.addLayout(grid1) - tdlabel = QtWidgets.QLabel('Tool dia:') + tdlabel = QtWidgets.QLabel(_tr('Tool dia:')) tdlabel.setToolTip( - "Diameter of the cutting tool.\n" + _tr("Diameter of the cutting tool.\n" "If you want to have an isolation path\n" "inside the actual shape of the Gerber\n" "feature, use a negative value for\n" - "this parameter." + "this parameter.") ) tdlabel.setFixedWidth(90) grid1.addWidget(tdlabel, 0, 0) self.iso_tool_dia_entry = LengthEntry() grid1.addWidget(self.iso_tool_dia_entry, 0, 1) - passlabel = QtWidgets.QLabel('Passes:') + passlabel = QtWidgets.QLabel(_tr('Passes:')) passlabel.setToolTip( - "Width of the isolation gap in\n" - "number (integer) of tool widths." + _tr("Width of the isolation gap in\n" + "number (integer) of tool widths.") ) passlabel.setFixedWidth(90) grid1.addWidget(passlabel, 1, 0) self.iso_width_entry = IntEntry() grid1.addWidget(self.iso_width_entry, 1, 1) - overlabel = QtWidgets.QLabel('Pass overlap:') + overlabel = QtWidgets.QLabel(_tr('Pass overlap:')) overlabel.setToolTip( - "How much (fraction) of the tool width to overlap each tool pass.\n" + _tr("How much (fraction) of the tool width to overlap each tool pass.\n" "Example:\n" - "A value here of 0.25 means an overlap of 25% from the tool diameter found above." + "A value here of 0.25 means an overlap of 25% from the tool diameter found above.") ) overlabel.setFixedWidth(90) grid1.addWidget(overlabel, 2, 0) @@ -354,37 +356,37 @@ class GerberObjectUI(ObjectUI): grid1.addWidget(self.iso_overlap_entry, 2, 1) # Milling Type Radio Button - self.milling_type_label = QtWidgets.QLabel('Milling Type:') + self.milling_type_label = QtWidgets.QLabel(_tr('Milling Type:')) self.milling_type_label.setToolTip( - "Milling type:\n" + _tr("Milling type:\n" "- climb / best for precision milling and to reduce tool usage\n" - "- conventional / useful when there is no backlash compensation" + "- conventional / useful when there is no backlash compensation") ) grid1.addWidget(self.milling_type_label, 3, 0) - self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'}, - {'label': 'Conv.', 'value': 'cv'}]) + self.milling_type_radio = RadioSet([{'label': _tr('Climb'), 'value': 'cl'}, + {'label': _tr('Conv.'), 'value': 'cv'}]) grid1.addWidget(self.milling_type_radio, 3, 1) # combine all passes CB - self.combine_passes_cb = FCCheckBox(label='Combine') + self.combine_passes_cb = FCCheckBox(label=_tr('Combine')) self.combine_passes_cb.setToolTip( - "Combine all passes into one object" + _tr("Combine all passes into one object") ) grid1.addWidget(self.combine_passes_cb, 4, 0) # generate follow - self.follow_cb = FCCheckBox(label='"Follow"') + self.follow_cb = FCCheckBox(label=_tr('"Follow"')) self.follow_cb.setToolTip( - "Generate a 'Follow' geometry.\n" + _tr( "Generate a 'Follow' geometry.\n" "This means that it will cut through\n" - "the middle of the trace." + "the middle of the trace.") ) grid1.addWidget(self.follow_cb, 4, 1) - self.gen_iso_label = QtWidgets.QLabel("Generate Isolation Geometry:") + self.gen_iso_label = QtWidgets.QLabel(_tr("Generate Isolation Geometry:")) self.gen_iso_label.setToolTip( - "Create a Geometry object with toolpaths to cut \n" + _tr("Create a Geometry object with toolpaths to cut \n" "isolation outside, inside or on both sides of the\n" "object. For a Gerber object outside means outside\n" "of the Gerber feature and inside means inside of\n" @@ -392,7 +394,7 @@ class GerberObjectUI(ObjectUI): "that only if the Gerber feature has openings inside, they\n" "will be isolated. If what is wanted is to cut isolation\n" "inside the actual Gerber feature, use a negative tool\n" - "diameter above." + "diameter above.") ) self.custom_box.addWidget(self.gen_iso_label) @@ -403,31 +405,31 @@ class GerberObjectUI(ObjectUI): self.padding_area_label.setFixedWidth(90) hlay_1.addWidget(self.padding_area_label) - self.generate_iso_button = QtWidgets.QPushButton('FULL Geo') + self.generate_iso_button = QtWidgets.QPushButton(_tr('FULL Geo')) self.generate_iso_button.setToolTip( - "Create the Geometry Object\n" + _tr("Create the Geometry Object\n" "for isolation routing. It contains both\n" - "the interiors and exteriors geometry." + "the interiors and exteriors geometry.") ) self.generate_iso_button.setFixedWidth(90) hlay_1.addWidget(self.generate_iso_button, alignment=Qt.AlignLeft) # hlay_1.addStretch() - self.generate_ext_iso_button = QtWidgets.QPushButton('Ext Geo') + self.generate_ext_iso_button = QtWidgets.QPushButton(_tr('Ext Geo')) self.generate_ext_iso_button.setToolTip( - "Create the Geometry Object\n" + _tr("Create the Geometry Object\n" "for isolation routing containing\n" - "only the exteriors geometry." + "only the exteriors geometry.") ) # self.generate_ext_iso_button.setFixedWidth(100) hlay_1.addWidget(self.generate_ext_iso_button) - self.generate_int_iso_button = QtWidgets.QPushButton('Int Geo') + self.generate_int_iso_button = QtWidgets.QPushButton(_tr('Int Geo')) self.generate_int_iso_button.setToolTip( - "Create the Geometry Object\n" + _tr("Create the Geometry Object\n" "for isolation routing containing\n" - "only the interiors geometry." + "only the interiors geometry.") ) # self.generate_ext_iso_button.setFixedWidth(90) hlay_1.addWidget(self.generate_int_iso_button) @@ -443,45 +445,45 @@ class GerberObjectUI(ObjectUI): self.custom_box.addLayout(grid2) ## Clear non-copper regions - self.clearcopper_label = QtWidgets.QLabel("Clear N-copper:") + self.clearcopper_label = QtWidgets.QLabel(_tr("Clear N-copper:")) self.clearcopper_label.setToolTip( - "Create a Geometry object with\n" - "toolpaths to cut all non-copper regions." + _tr("Create a Geometry object with\n" + "toolpaths to cut all non-copper regions.") ) self.clearcopper_label.setFixedWidth(90) grid2.addWidget(self.clearcopper_label, 0, 0) - self.generate_ncc_button = QtWidgets.QPushButton('NCC Tool') + self.generate_ncc_button = QtWidgets.QPushButton(_tr('NCC Tool')) self.generate_ncc_button.setToolTip( - "Create the Geometry Object\n" - "for non-copper routing." + _tr("Create the Geometry Object\n" + "for non-copper routing.") ) grid2.addWidget(self.generate_ncc_button, 0, 1) ## Board cutout - self.board_cutout_label = QtWidgets.QLabel("Board cutout:") + self.board_cutout_label = QtWidgets.QLabel(_tr("Board cutout:")) self.board_cutout_label.setToolTip( - "Create toolpaths to cut around\n" + _tr("Create toolpaths to cut around\n" "the PCB and separate it from\n" - "the original board." + "the original board.") ) grid2.addWidget(self.board_cutout_label, 1, 0) - self.generate_cutout_button = QtWidgets.QPushButton('Cutout Tool') + self.generate_cutout_button = QtWidgets.QPushButton(_tr('Cutout Tool')) self.generate_cutout_button.setToolTip( - "Generate the geometry for\n" - "the board cutout." + _tr("Generate the geometry for\n" + "the board cutout.") ) grid2.addWidget(self.generate_cutout_button, 1, 1) ## Non-copper regions - self.noncopper_label = QtWidgets.QLabel("Non-copper regions:") + self.noncopper_label = QtWidgets.QLabel(_tr("Non-copper regions:")) self.noncopper_label.setToolTip( - "Create polygons covering the\n" + _tr("Create polygons covering the\n" "areas without copper on the PCB.\n" "Equivalent to the inverse of this\n" "object. Can be used to remove all\n" - "copper from a specified region." + "copper from a specified region.") ) self.custom_box.addWidget(self.noncopper_label) @@ -489,12 +491,12 @@ class GerberObjectUI(ObjectUI): self.custom_box.addLayout(grid4) # Margin - bmlabel = QtWidgets.QLabel('Boundary Margin:') + bmlabel = QtWidgets.QLabel(_tr('Boundary Margin:')) bmlabel.setToolTip( - "Specify the edge of the PCB\n" + _tr("Specify the edge of the PCB\n" "by drawing a box around all\n" "objects with this minimum\n" - "distance." + "distance.") ) bmlabel.setFixedWidth(90) grid4.addWidget(bmlabel, 0, 0) @@ -502,50 +504,50 @@ class GerberObjectUI(ObjectUI): grid4.addWidget(self.noncopper_margin_entry, 0, 1) # Rounded corners - self.noncopper_rounded_cb = FCCheckBox(label="Rounded Geo") + self.noncopper_rounded_cb = FCCheckBox(label=_tr("Rounded Geo")) self.noncopper_rounded_cb.setToolTip( - "Resulting geometry will have rounded corners." + _tr("Resulting geometry will have rounded corners.") ) self.noncopper_rounded_cb.setFixedWidth(90) grid4.addWidget(self.noncopper_rounded_cb, 1, 0) - self.generate_noncopper_button = QtWidgets.QPushButton('Generate Geo') + self.generate_noncopper_button = QtWidgets.QPushButton(_tr('Generate Geo')) grid4.addWidget(self.generate_noncopper_button, 1, 1) ## Bounding box - self.boundingbox_label = QtWidgets.QLabel('Bounding Box:') + self.boundingbox_label = QtWidgets.QLabel(_tr('Bounding Box:')) self.boundingbox_label.setToolTip( - "Create a geometry surrounding the Gerber object.\n" - "Square shape." + _tr("Create a geometry surrounding the Gerber object.\n" + "Square shape.") ) self.custom_box.addWidget(self.boundingbox_label) grid5 = QtWidgets.QGridLayout() self.custom_box.addLayout(grid5) - bbmargin = QtWidgets.QLabel('Boundary Margin:') + bbmargin = QtWidgets.QLabel(_tr('Boundary Margin:')) bbmargin.setToolTip( - "Distance of the edges of the box\n" - "to the nearest polygon." + _tr("Distance of the edges of the box\n" + "to the nearest polygon.") ) bbmargin.setFixedWidth(90) grid5.addWidget(bbmargin, 0, 0) self.bbmargin_entry = LengthEntry() grid5.addWidget(self.bbmargin_entry, 0, 1) - self.bbrounded_cb = FCCheckBox(label="Rounded Geo") + self.bbrounded_cb = FCCheckBox(label=_tr("Rounded Geo")) self.bbrounded_cb.setToolTip( - "If the bounding box is \n" + _tr("If the bounding box is \n" "to have rounded corners\n" "their radius is equal to\n" - "the margin." + "the margin.") ) self.bbrounded_cb.setFixedWidth(90) grid5.addWidget(self.bbrounded_cb, 1, 0) - self.generate_bb_button = QtWidgets.QPushButton('Generate Geo') + self.generate_bb_button = QtWidgets.QPushButton(_tr('Generate Geo')) self.generate_bb_button.setToolTip( - "Generate the Geometry object." + _tr("Generate the Geometry object.") ) grid5.addWidget(self.generate_bb_button, 1, 1) @@ -556,7 +558,7 @@ class ExcellonObjectUI(ObjectUI): """ def __init__(self, parent=None): - ObjectUI.__init__(self, title='Excellon Object', + ObjectUI.__init__(self, title=_tr('Excellon Object'), icon_file='share/drill32.png', parent=parent) @@ -564,10 +566,10 @@ class ExcellonObjectUI(ObjectUI): hlay_plot = QtWidgets.QHBoxLayout() self.custom_box.addLayout(hlay_plot) - self.plot_options_label = QtWidgets.QLabel("Plot Options:") - self.solid_cb = FCCheckBox(label='Solid') + self.plot_options_label = QtWidgets.QLabel(_tr("Plot Options:")) + self.solid_cb = FCCheckBox(label=_tr('Solid')) self.solid_cb.setToolTip( - "Solid circles." + _tr("Solid circles.") ) hlay_plot.addWidget(self.plot_options_label) hlay_plot.addStretch() @@ -576,7 +578,7 @@ class ExcellonObjectUI(ObjectUI): ## Object name self.name_hlay = QtWidgets.QHBoxLayout() self.custom_box.addLayout(self.name_hlay) - name_label = QtWidgets.QLabel("Name:") + name_label = QtWidgets.QLabel(_tr("Name:")) self.name_entry = FCEntry() self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus) self.name_hlay.addWidget(name_label) @@ -595,17 +597,17 @@ class ExcellonObjectUI(ObjectUI): self.tools_box.addLayout(hlay_plot) #### Tools Drills #### - self.tools_table_label = QtWidgets.QLabel('Tools Table') + self.tools_table_label = QtWidgets.QLabel(_tr('Tools Table')) self.tools_table_label.setToolTip( - "Tools in this Excellon object\n" - "when are used for drilling." + _tr("Tools in this Excellon object\n" + "when are used for drilling.") ) hlay_plot.addWidget(self.tools_table_label) # Plot CB - self.plot_cb = FCCheckBox('Plot Object') + self.plot_cb = FCCheckBox(_tr('Plot Object')) self.plot_cb.setToolTip( - "Plot (show) this object." + _tr("Plot (show) this object.") ) self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft) hlay_plot.addStretch() @@ -615,37 +617,38 @@ class ExcellonObjectUI(ObjectUI): self.tools_box.addWidget(self.tools_table) self.tools_table.setColumnCount(6) - self.tools_table.setHorizontalHeaderLabels(['#', 'Diameter', 'Drills', 'Slots', 'Offset Z', 'P']) + self.tools_table.setHorizontalHeaderLabels(['#', _tr('Diameter'), _tr('Drills'), _tr('Slots'), + _tr('Offset Z'), 'P']) self.tools_table.setSortingEnabled(False) self.tools_table.horizontalHeaderItem(0).setToolTip( - "This is the Tool Number.\n" + _tr("This is the Tool Number.\n" "When ToolChange is checked, on toolchange event this value\n" - "will be showed as a T1, T2 ... Tn in the Machine Code.") + "will be showed as a T1, T2 ... Tn in the Machine Code.")) self.tools_table.horizontalHeaderItem(1).setToolTip( - "Tool Diameter. It's value (in current FlatCAM units) \n" - "is the cut width into the material.") + _tr("Tool Diameter. It's value (in current FlatCAM units) \n" + "is the cut width into the material.")) self.tools_table.horizontalHeaderItem(2).setToolTip( - "The number of Drill holes. Holes that are drilled with\n" - "a drill bit.") + _tr("The number of Drill holes. Holes that are drilled with\n" + "a drill bit.")) self.tools_table.horizontalHeaderItem(3).setToolTip( - "The number of Slot holes. Holes that are created by\n" - "milling them with an endmill bit.") + _tr("The number of Slot holes. Holes that are created by\n" + "milling them with an endmill bit.")) self.tools_table.horizontalHeaderItem(4).setToolTip( - "Some drill bits (the larger ones) need to drill deeper\n" + _tr("Some drill bits (the larger ones) need to drill deeper\n" "to create the desired exit hole diameter due of the tip shape.\n" - "The value here can compensate the Cut Z parameter.") + "The value here can compensate the Cut Z parameter.")) self.tools_table.horizontalHeaderItem(5).setToolTip( - "Toggle display of the drills for the current tool.") + _tr("Toggle display of the drills for the current tool.")) self.empty_label = QtWidgets.QLabel('') self.tools_box.addWidget(self.empty_label) #### Create CNC Job #### - self.cncjob_label = QtWidgets.QLabel('Create CNC Job') + self.cncjob_label = QtWidgets.QLabel(_tr('Create CNC Job')) self.cncjob_label.setToolTip( - "Create a CNC Job object\n" - "for this drill object." + _tr("Create a CNC Job object\n" + "for this drill object.") ) self.tools_box.addWidget(self.cncjob_label) @@ -653,38 +656,38 @@ class ExcellonObjectUI(ObjectUI): self.tools_box.addLayout(grid1) # Cut Z - cutzlabel = QtWidgets.QLabel('Cut Z:') + cutzlabel = QtWidgets.QLabel(_tr('Cut Z:')) cutzlabel.setToolTip( - "Drill depth (negative)\n" - "below the copper surface." + _tr("Drill depth (negative)\n" + "below the copper surface.") ) grid1.addWidget(cutzlabel, 0, 0) self.cutz_entry = LengthEntry() grid1.addWidget(self.cutz_entry, 0, 1) # Travel Z (z_move) - travelzlabel = QtWidgets.QLabel('Travel Z:') + travelzlabel = QtWidgets.QLabel(_tr('Travel Z:')) travelzlabel.setToolTip( - "Tool height when travelling\n" - "across the XY plane." + _tr("Tool height when travelling\n" + "across the XY plane.") ) grid1.addWidget(travelzlabel, 1, 0) self.travelz_entry = LengthEntry() grid1.addWidget(self.travelz_entry, 1, 1) # Tool change: - self.toolchange_cb = FCCheckBox("Tool change") + self.toolchange_cb = FCCheckBox(_tr("Tool change")) self.toolchange_cb.setToolTip( - "Include tool-change sequence\n" - "in G-Code (Pause for tool change)." + _tr("Include tool-change sequence\n" + "in G-Code (Pause for tool change).") ) grid1.addWidget(self.toolchange_cb, 2, 0) # Tool change Z: - toolchzlabel = QtWidgets.QLabel("Tool change Z:") + toolchzlabel = QtWidgets.QLabel(_tr("Tool change Z:")) toolchzlabel.setToolTip( - "Z-axis position (height) for\n" - "tool change." + _tr("Z-axis position (height) for\n" + "tool change.") ) grid1.addWidget(toolchzlabel, 3, 0) self.toolchangez_entry = LengthEntry() @@ -692,66 +695,66 @@ class ExcellonObjectUI(ObjectUI): self.ois_tcz_e = OptionalInputSection(self.toolchange_cb, [self.toolchangez_entry]) # Start move Z: - self.estartz_label = QtWidgets.QLabel("Start move Z:") + self.estartz_label = QtWidgets.QLabel(_tr("Start move Z:")) self.estartz_label.setToolTip( - "Tool height just before starting the work.\n" - "Delete the value if you don't need this feature." + _tr("Tool height just before starting the work.\n" + "Delete the value if you don't need this feature.") ) grid1.addWidget(self.estartz_label, 4, 0) self.estartz_entry = FloatEntry() grid1.addWidget(self.estartz_entry, 4, 1) # End move Z: - self.eendz_label = QtWidgets.QLabel("End move Z:") + self.eendz_label = QtWidgets.QLabel(_tr("End move Z:")) self.eendz_label.setToolTip( - "Z-axis position (height) for\n" - "the last move." + _tr("Z-axis position (height) for\n" + "the last move.") ) grid1.addWidget(self.eendz_label, 5, 0) self.eendz_entry = LengthEntry() grid1.addWidget(self.eendz_entry, 5, 1) # Excellon Feedrate - frlabel = QtWidgets.QLabel('Feedrate (Plunge):') + frlabel = QtWidgets.QLabel(_tr('Feedrate (Plunge):')) frlabel.setToolTip( - "Tool speed while drilling\n" + _tr("Tool speed while drilling\n" "(in units per minute).\n" - "This is for linear move G01." + "This is for linear move G01.") ) grid1.addWidget(frlabel, 6, 0) self.feedrate_entry = LengthEntry() grid1.addWidget(self.feedrate_entry, 6, 1) # Excellon Rapid Feedrate - self.feedrate_rapid_label = QtWidgets.QLabel('Feedrate Rapids:') + self.feedrate_rapid_label = QtWidgets.QLabel(_tr('Feedrate Rapids:')) self.feedrate_rapid_label.setToolTip( - "Tool speed while drilling\n" + _tr("Tool speed while drilling\n" "(in units per minute).\n" - "This is for the rapid move G00." + "This is for the rapid move G00.") ) grid1.addWidget(self.feedrate_rapid_label, 7, 0) self.feedrate_rapid_entry = LengthEntry() grid1.addWidget(self.feedrate_rapid_entry, 7, 1) # Spindlespeed - spdlabel = QtWidgets.QLabel('Spindle speed:') + spdlabel = QtWidgets.QLabel(_tr('Spindle speed:')) spdlabel.setToolTip( - "Speed of the spindle\n" - "in RPM (optional)" + _tr("Speed of the spindle\n" + "in RPM (optional)") ) grid1.addWidget(spdlabel, 8, 0) self.spindlespeed_entry = IntEntry(allow_empty=True) grid1.addWidget(self.spindlespeed_entry, 8, 1) # Dwell - self.dwell_cb = FCCheckBox('Dwell:') + self.dwell_cb = FCCheckBox(_tr('Dwell:')) self.dwell_cb.setToolTip( - "Pause to allow the spindle to reach its\n" - "speed before cutting." + _tr("Pause to allow the spindle to reach its\n" + "speed before cutting.") ) self.dwelltime_entry = FCEntry() self.dwelltime_entry.setToolTip( - "Number of milliseconds for spindle to dwell." + _tr("Number of milliseconds for spindle to dwell.") ) grid1.addWidget(self.dwell_cb, 9, 0) grid1.addWidget(self.dwelltime_entry, 9, 1) @@ -759,10 +762,10 @@ class ExcellonObjectUI(ObjectUI): self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry]) # postprocessor selection - pp_excellon_label = QtWidgets.QLabel("Postprocessor:") + pp_excellon_label = QtWidgets.QLabel(_tr("Postprocessor:")) pp_excellon_label.setToolTip( - "The json file that dictates\n" - "gcode output." + _tr("The json file that dictates\n" + "gcode output.") ) self.pp_excellon_name_cb = FCComboBox() self.pp_excellon_name_cb.setFocusPolicy(QtCore.Qt.StrongFocus) @@ -770,10 +773,10 @@ class ExcellonObjectUI(ObjectUI): grid1.addWidget(self.pp_excellon_name_cb, 10, 1) # Probe depth - self.pdepth_label = QtWidgets.QLabel("Probe Z depth:") + self.pdepth_label = QtWidgets.QLabel(_tr("Probe Z depth:")) self.pdepth_label.setToolTip( - "The maximum depth that the probe is allowed\n" - "to probe. Negative value, in current units." + _tr("The maximum depth that the probe is allowed\n" + "to probe. Negative value, in current units.") ) grid1.addWidget(self.pdepth_label, 11, 0) self.pdepth_entry = FCEntry() @@ -782,9 +785,9 @@ class ExcellonObjectUI(ObjectUI): self.pdepth_entry.setVisible(False) # Probe feedrate - self.feedrate_probe_label = QtWidgets.QLabel("Feedrate Probe:") + self.feedrate_probe_label = QtWidgets.QLabel(_tr("Feedrate Probe:")) self.feedrate_probe_label.setToolTip( - "The feedrate used while the probe is probing." + _tr("The feedrate used while the probe is probing.") ) grid1.addWidget(self.feedrate_probe_label, 12, 0) self.feedrate_probe_entry = FCEntry() @@ -793,23 +796,23 @@ class ExcellonObjectUI(ObjectUI): self.feedrate_probe_entry.setVisible(False) choose_tools_label = QtWidgets.QLabel( - "Select from the Tools Table above\n" - "the tools you want to include." + _tr("Select from the Tools Table above\n" + "the tools you want to include.") ) self.tools_box.addWidget(choose_tools_label) #### Choose what to use for Gcode creation: Drills, Slots or Both gcode_box = QtWidgets.QFormLayout() - gcode_type_label = QtWidgets.QLabel('Type: ') + gcode_type_label = QtWidgets.QLabel(_tr('Type: ')) gcode_type_label.setToolTip( - "Choose what to use for GCode generation:\n" + _tr("Choose what to use for GCode generation:\n" "'Drills', 'Slots' or 'Both'.\n" "When choosing 'Slots' or 'Both', slots will be\n" - "converted to a series of drills." + "converted to a series of drills.") ) - self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'}, - {'label': 'Slots', 'value': 'slots'}, - {'label': 'Both', 'value': 'both'}]) + self.excellon_gcode_type_radio = RadioSet([{'label': _tr('Drills'), 'value': 'drills'}, + {'label': _tr('Slots'), 'value': 'slots'}, + {'label': _tr('Both'), 'value': 'both'}]) gcode_box.addRow(gcode_type_label, self.excellon_gcode_type_radio) self.tools_box.addLayout(gcode_box) @@ -817,54 +820,54 @@ class ExcellonObjectUI(ObjectUI): self.excellon_gcode_type_radio.setVisible(False) gcode_type_label.hide() - self.generate_cnc_button = QtWidgets.QPushButton('Create GCode') + self.generate_cnc_button = QtWidgets.QPushButton(_tr('Create GCode')) self.generate_cnc_button.setToolTip( - "Generate the CNC Job." + _tr("Generate the CNC Job.") ) self.tools_box.addWidget(self.generate_cnc_button) #### Milling Holes Drills#### - self.mill_hole_label = QtWidgets.QLabel('Mill Holes') + self.mill_hole_label = QtWidgets.QLabel(_tr('Mill Holes')) self.mill_hole_label.setToolTip( - "Create Geometry for milling holes." + _tr("Create Geometry for milling holes.") ) self.tools_box.addWidget(self.mill_hole_label) self.choose_tools_label2 = QtWidgets.QLabel( - "Select from the Tools Table above\n" - " the hole dias that are to be milled." + _tr("Select from the Tools Table above\n" + " the hole dias that are to be milled.") ) self.tools_box.addWidget(self.choose_tools_label2) grid2 = QtWidgets.QGridLayout() self.tools_box.addLayout(grid2) - self.tdlabel = QtWidgets.QLabel('Drills Tool dia:') + self.tdlabel = QtWidgets.QLabel(_tr('Drills Tool dia:')) self.tdlabel.setToolTip( - "Diameter of the cutting tool." + _tr("Diameter of the cutting tool.") ) grid2.addWidget(self.tdlabel, 0, 0) self.tooldia_entry = LengthEntry() grid2.addWidget(self.tooldia_entry, 0, 1) - self.generate_milling_button = QtWidgets.QPushButton('Mill Drills Geo') + self.generate_milling_button = QtWidgets.QPushButton(_tr('Mill Drills Geo')) self.generate_milling_button.setToolTip( - "Create the Geometry Object\n" - "for milling DRILLS toolpaths." + _tr("Create the Geometry Object\n" + "for milling DRILLS toolpaths.") ) grid2.addWidget(self.generate_milling_button, 0, 2) grid3 = QtWidgets.QGridLayout() self.custom_box.addLayout(grid3) - self.stdlabel = QtWidgets.QLabel('Slots Tool dia:') + self.stdlabel = QtWidgets.QLabel(_tr('Slots Tool dia:')) self.stdlabel.setToolTip( - "Diameter of the cutting tool." + _tr("Diameter of the cutting tool.") ) grid3.addWidget(self.stdlabel, 0, 0) self.slot_tooldia_entry = LengthEntry() grid3.addWidget(self.slot_tooldia_entry, 0, 1) - self.generate_milling_slots_button = QtWidgets.QPushButton('Mill Slots Geo') + self.generate_milling_slots_button = QtWidgets.QPushButton(_tr('Mill Slots Geo')) self.generate_milling_slots_button.setToolTip( - "Create the Geometry Object\n" - "for milling SLOTS toolpaths." + _tr("Create the Geometry Object\n" + "for milling SLOTS toolpaths.") ) grid3.addWidget(self.generate_milling_slots_button, 0, 2) @@ -881,16 +884,17 @@ class GeometryObjectUI(ObjectUI): """ def __init__(self, parent=None): - super(GeometryObjectUI, self).__init__(title='Geometry Object', icon_file='share/geometry32.png', parent=parent) + super(GeometryObjectUI, self).__init__(title=_tr('Geometry Object'), + icon_file='share/geometry32.png', parent=parent) # Plot options - self.plot_options_label = QtWidgets.QLabel("Plot Options:") + self.plot_options_label = QtWidgets.QLabel(_tr("Plot Options:")) self.custom_box.addWidget(self.plot_options_label) ## Object name self.name_hlay = QtWidgets.QHBoxLayout() self.custom_box.addLayout(self.name_hlay) - name_label = QtWidgets.QLabel("Name:") + name_label = QtWidgets.QLabel(_tr("Name:")) self.name_entry = FCEntry() self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus) self.name_hlay.addWidget(name_label) @@ -909,9 +913,9 @@ class GeometryObjectUI(ObjectUI): self.geo_tools_box.addLayout(hlay_plot) #### Tools #### - self.tools_table_label = QtWidgets.QLabel('Tools Table') + self.tools_table_label = QtWidgets.QLabel(_tr('Tools Table')) self.tools_table_label.setToolTip( - "Tools in this Geometry object used for cutting.\n" + _tr("Tools in this Geometry object used for cutting.\n" "The 'Offset' entry will set an offset for the cut.\n" "'Offset' can be inside, outside, on path (none) and custom.\n" "'Type' entry is only informative and it allow to know the \n" @@ -922,15 +926,15 @@ class GeometryObjectUI(ObjectUI): "When V-shaped is selected the 'Type' entry is automatically \n" "set to Isolation, the CutZ parameter in the UI form is\n" "grayed out and Cut Z is automatically calculated from the newly \n" - "showed UI form entries named V-Tip Dia and V-Tip Angle." + "showed UI form entries named V-Tip Dia and V-Tip Angle.") ) hlay_plot.addWidget(self.tools_table_label) # Plot CB # self.plot_cb = QtWidgets.QCheckBox('Plot') - self.plot_cb = FCCheckBox('Plot Object') + self.plot_cb = FCCheckBox(_tr('Plot Object')) self.plot_cb.setToolTip( - "Plot (show) this object." + _tr("Plot (show) this object.") ) self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft) hlay_plot.addStretch() @@ -942,44 +946,56 @@ class GeometryObjectUI(ObjectUI): self.geo_tools_table.setColumnCount(7) self.geo_tools_table.setColumnWidth(0, 20) - self.geo_tools_table.setHorizontalHeaderLabels(['#', 'Dia', 'Offset', 'Type', 'TT', '', 'P']) + self.geo_tools_table.setHorizontalHeaderLabels(['#', _tr('Dia'), _tr('Offset'), _tr('Type'), _tr('TT'), '', 'P']) self.geo_tools_table.setColumnHidden(5, True) # stylesheet = "::section{Background-color:rgb(239,239,245)}" # self.geo_tools_table.horizontalHeader().setStyleSheet(stylesheet) self.geo_tools_table.horizontalHeaderItem(0).setToolTip( - "This is the Tool Number.\n" - "When ToolChange is checked, on toolchange event this value\n" - "will be showed as a T1, T2 ... Tn") + _tr( + "This is the Tool Number.\n" + "When ToolChange is checked, on toolchange event this value\n" + "will be showed as a T1, T2 ... Tn") + ) self.geo_tools_table.horizontalHeaderItem(1).setToolTip( - "Tool Diameter. It's value (in current FlatCAM units) \n" - "is the cut width into the material.") + _tr( + "Tool Diameter. It's value (in current FlatCAM units) \n" + "is the cut width into the material." + )) self.geo_tools_table.horizontalHeaderItem(2).setToolTip( - "The value for the Offset can be:\n" - "- Path -> There is no offset, the tool cut will be done through the geometry line.\n" - "- In(side) -> The tool cut will follow the geometry inside. It will create a 'pocket'.\n" - "- Out(side) -> The tool cut will follow the geometry line on the outside.") + _tr( + "The value for the Offset can be:\n" + "- Path -> There is no offset, the tool cut will be done through the geometry line.\n" + "- In(side) -> The tool cut will follow the geometry inside. It will create a 'pocket'.\n" + "- Out(side) -> The tool cut will follow the geometry line on the outside." + )) self.geo_tools_table.horizontalHeaderItem(3).setToolTip( - "The (Operation) Type has only informative value. Usually the UI form values \n" - "are choosed based on the operation type and this will serve as a reminder.\n" - "Can be 'Roughing', 'Finishing' or 'Isolation'.\n" - "For Roughing we may choose a lower Feedrate and multiDepth cut.\n" - "For Finishing we may choose a higher Feedrate, without multiDepth.\n" - "For Isolation we need a lower Feedrate as it use a milling bit with a fine tip.") + _tr( + "The (Operation) Type has only informative value. Usually the UI form values \n" + "are choosed based on the operation type and this will serve as a reminder.\n" + "Can be 'Roughing', 'Finishing' or 'Isolation'.\n" + "For Roughing we may choose a lower Feedrate and multiDepth cut.\n" + "For Finishing we may choose a higher Feedrate, without multiDepth.\n" + "For Isolation we need a lower Feedrate as it use a milling bit with a fine tip." + )) self.geo_tools_table.horizontalHeaderItem(4).setToolTip( - "The Tool Type (TT) can be:\n" - "- Circular with 1 ... 4 teeth -> it is informative only. Being circular the cut width in material\n" - "is exactly the tool diameter.\n" - "- Ball -> informative only and make reference to the Ball type endmill.\n" - "- V-Shape -> it will disable de Z-Cut parameter in the UI form and enable two additional UI form\n" - "fields: V-Tip Dia and V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such\n" - "as the cut width into material will be equal with the value in the Tool Diameter column of this table.\n" - "Choosing the V-Shape Tool Type automatically will select the Operation Type as Isolation.") + _tr( + "The Tool Type (TT) can be:\n" + "- Circular with 1 ... 4 teeth -> it is informative only. Being circular the cut width in material\n" + "is exactly the tool diameter.\n" + "- Ball -> informative only and make reference to the Ball type endmill.\n" + "- V-Shape -> it will disable de Z-Cut parameter in the UI form and enable two additional UI form\n" + "fields: V-Tip Dia and V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such\n" + "as the cut width into material will be equal with the value in the Tool Diameter column of this table.\n" + "Choosing the V-Shape Tool Type automatically will select the Operation Type as Isolation." + )) self.geo_tools_table.horizontalHeaderItem(6).setToolTip( - "Plot column. It is visible only for MultiGeo geometries, meaning geometries that holds the geometry\n" - "data into the tools. For those geometries, deleting the tool will delete the geometry data also,\n" - "so be WARNED. From the checkboxes on each row it can be enabled/disabled the plot on canvas\n" - "for the corresponding tool.") + _tr( + "Plot column. It is visible only for MultiGeo geometries, meaning geometries that holds the geometry\n" + "data into the tools. For those geometries, deleting the tool will delete the geometry data also,\n" + "so be WARNED. From the checkboxes on each row it can be enabled/disabled the plot on canvas\n" + "for the corresponding tool." + )) # self.geo_tools_table.setSortingEnabled(False) # self.geo_tools_table.setSelectionBehavior(QtWidgets.QAbstractItemView.SelectRows) @@ -988,12 +1004,14 @@ class GeometryObjectUI(ObjectUI): self.grid1 = QtWidgets.QGridLayout() self.geo_tools_box.addLayout(self.grid1) - self.tool_offset_lbl = QtWidgets.QLabel('Tool Offset:') + self.tool_offset_lbl = QtWidgets.QLabel(_tr('Tool Offset:')) self.tool_offset_lbl.setToolTip( - "The value to offset the cut when \n" - "the Offset type selected is 'Offset'.\n" - "The value can be positive for 'outside'\n" - "cut and negative for 'inside' cut." + _tr( + "The value to offset the cut when \n" + "the Offset type selected is 'Offset'.\n" + "The value can be positive for 'outside'\n" + "cut and negative for 'inside' cut." + ) ) self.grid1.addWidget(self.tool_offset_lbl, 0, 0) self.tool_offset_entry = FloatEntry() @@ -1012,9 +1030,11 @@ class GeometryObjectUI(ObjectUI): # self.addtool_label.setToolTip( # "Add/Copy/Delete a tool to the tool list." # ) - self.addtool_entry_lbl = QtWidgets.QLabel('Tool Dia:') + self.addtool_entry_lbl = QtWidgets.QLabel(_tr('Tool Dia:')) self.addtool_entry_lbl.setToolTip( - "Diameter for the new tool" + _tr( + "Diameter for the new tool" + ) ) self.addtool_entry = FCEntry() @@ -1026,22 +1046,28 @@ class GeometryObjectUI(ObjectUI): grid2 = QtWidgets.QGridLayout() self.geo_tools_box.addLayout(grid2) - self.addtool_btn = QtWidgets.QPushButton('Add') + self.addtool_btn = QtWidgets.QPushButton(_tr('Add')) self.addtool_btn.setToolTip( - "Add a new tool to the Tool Table\n" - "with the diameter specified above." + _tr( + "Add a new tool to the Tool Table\n" + "with the diameter specified above." + ) ) - self.copytool_btn = QtWidgets.QPushButton('Copy') + self.copytool_btn = QtWidgets.QPushButton(_tr('Copy')) self.copytool_btn.setToolTip( - "Copy a selection of tools in the Tool Table\n" - "by first selecting a row in the Tool Table." + _tr( + "Copy a selection of tools in the Tool Table\n" + "by first selecting a row in the Tool Table." + ) ) - self.deltool_btn = QtWidgets.QPushButton('Delete') + self.deltool_btn = QtWidgets.QPushButton(_tr('Delete')) self.deltool_btn.setToolTip( - "Delete a selection of tools in the Tool Table\n" - "by first selecting a row in the Tool Table." + _tr( + "Delete a selection of tools in the Tool Table\n" + "by first selecting a row in the Tool Table." + ) ) grid2.addWidget(self.addtool_btn, 0, 0) @@ -1055,10 +1081,12 @@ class GeometryObjectUI(ObjectUI): # Create CNC Job #----------------------------------- #### Tools Data #### - self.tool_data_label = QtWidgets.QLabel('Tool Data') + self.tool_data_label = QtWidgets.QLabel(_tr('Tool Data')) self.tool_data_label.setToolTip( - "The data used for creating GCode.\n" - "Each tool store it's own set of such data." + _tr( + "The data used for creating GCode.\n" + "Each tool store it's own set of such data." + ) ) self.geo_tools_box.addWidget(self.tool_data_label) @@ -1066,59 +1094,71 @@ class GeometryObjectUI(ObjectUI): self.geo_tools_box.addLayout(self.grid3) # Tip Dia - self.tipdialabel = QtWidgets.QLabel('V-Tip Dia:') + self.tipdialabel = QtWidgets.QLabel(_tr('V-Tip Dia:')) self.tipdialabel.setToolTip( - "The tip diameter for V-Shape Tool" + _tr( + "The tip diameter for V-Shape Tool" + ) ) self.grid3.addWidget(self.tipdialabel, 1, 0) self.tipdia_entry = LengthEntry() self.grid3.addWidget(self.tipdia_entry, 1, 1) # Tip Angle - self.tipanglelabel = QtWidgets.QLabel('V-Tip Angle:') + self.tipanglelabel = QtWidgets.QLabel(_tr('V-Tip Angle:')) self.tipanglelabel.setToolTip( - "The tip angle for V-Shape Tool.\n" - "In degree." + _tr( + "The tip angle for V-Shape Tool.\n" + "In degree." + ) ) self.grid3.addWidget(self.tipanglelabel, 2, 0) self.tipangle_entry = LengthEntry() self.grid3.addWidget(self.tipangle_entry, 2, 1) # Cut Z - cutzlabel = QtWidgets.QLabel('Cut Z:') + cutzlabel = QtWidgets.QLabel(_tr('Cut Z:')) cutzlabel.setToolTip( - "Cutting depth (negative)\n" - "below the copper surface." + _tr( + "Cutting depth (negative)\n" + "below the copper surface." + ) ) self.grid3.addWidget(cutzlabel, 3, 0) self.cutz_entry = LengthEntry() self.grid3.addWidget(self.cutz_entry, 3, 1) # Multi-pass - self.mpass_cb = FCCheckBox("Multi-Depth:") + self.mpass_cb = FCCheckBox(_tr("Multi-Depth:")) self.mpass_cb.setToolTip( - "Use multiple passes to limit\n" - "the cut depth in each pass. Will\n" - "cut multiple times until Cut Z is\n" - "reached.\n" - "To the right, input the depth of \n" - "each pass (positive value)." + _tr( + "Use multiple passes to limit\n" + "the cut depth in each pass. Will\n" + "cut multiple times until Cut Z is\n" + "reached.\n" + "To the right, input the depth of \n" + "each pass (positive value)." + ) ) self.grid3.addWidget(self.mpass_cb, 4, 0) self.maxdepth_entry = LengthEntry() self.maxdepth_entry.setToolTip( - "Depth of each pass (positive)." + _tr( + "Depth of each pass (positive)." + ) ) self.grid3.addWidget(self.maxdepth_entry, 4, 1) self.ois_mpass_geo = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry]) # Travel Z - travelzlabel = QtWidgets.QLabel('Travel Z:') + travelzlabel = QtWidgets.QLabel(_tr('Travel Z:')) travelzlabel.setToolTip( - "Height of the tool when\n" - "moving without cutting." + _tr( + "Height of the tool when\n" + "moving without cutting." + ) ) self.grid3.addWidget(travelzlabel, 5, 0) self.travelz_entry = LengthEntry() @@ -1126,15 +1166,19 @@ class GeometryObjectUI(ObjectUI): # Tool change: - self.toolchzlabel = QtWidgets.QLabel("Tool change Z:") + self.toolchzlabel = QtWidgets.QLabel(_tr("Tool change Z:")) self.toolchzlabel.setToolTip( - "Z-axis position (height) for\n" - "tool change." + _tr( + "Z-axis position (height) for\n" + "tool change." + ) ) - self.toolchangeg_cb = FCCheckBox("Tool change") + self.toolchangeg_cb = FCCheckBox(_tr("Tool change")) self.toolchangeg_cb.setToolTip( - "Include tool-change sequence\n" - "in the Machine Code (Pause for tool change)." + _tr( + "Include tool-change sequence\n" + "in the Machine Code (Pause for tool change)." + ) ) self.toolchangez_entry = LengthEntry() @@ -1155,76 +1199,92 @@ class GeometryObjectUI(ObjectUI): # self.grid3.addWidget(self.gstartz_entry, 8, 1) # The Z value for the end move - self.endzlabel = QtWidgets.QLabel('End move Z:') + self.endzlabel = QtWidgets.QLabel(_tr('End move Z:')) self.endzlabel.setToolTip( - "This is the height (Z) at which the CNC\n" - "will go as the last move." + _tr( + "This is the height (Z) at which the CNC\n" + "will go as the last move." + ) ) self.grid3.addWidget(self.endzlabel, 9, 0) self.gendz_entry = LengthEntry() self.grid3.addWidget(self.gendz_entry, 9, 1) # Feedrate X-Y - frlabel = QtWidgets.QLabel('Feed Rate X-Y:') + frlabel = QtWidgets.QLabel(_tr('Feed Rate X-Y:')) frlabel.setToolTip( - "Cutting speed in the XY\n" - "plane in units per minute" + _tr( + "Cutting speed in the XY\n" + "plane in units per minute" + ) ) self.grid3.addWidget(frlabel, 10, 0) self.cncfeedrate_entry = LengthEntry() self.grid3.addWidget(self.cncfeedrate_entry, 10, 1) # Feedrate Z (Plunge) - frzlabel = QtWidgets.QLabel('Feed Rate Z (Plunge):') + frzlabel = QtWidgets.QLabel(_tr('Feed Rate Z (Plunge):')) frzlabel.setToolTip( - "Cutting speed in the Z\n" - "plane in units per minute" + _tr( + "Cutting speed in the Z\n" + "plane in units per minute" + ) ) self.grid3.addWidget(frzlabel, 11, 0) self.cncplunge_entry = LengthEntry() self.grid3.addWidget(self.cncplunge_entry, 11, 1) # Feedrate rapids - self.fr_rapidlabel = QtWidgets.QLabel('Feed Rate Rapids:') + self.fr_rapidlabel = QtWidgets.QLabel(_tr('Feed Rate Rapids:')) self.fr_rapidlabel.setToolTip( - "Cutting speed in the XY\n" - "plane in units per minute\n" - "for the rapid movements" + _tr( + "Cutting speed in the XY\n" + "plane in units per minute\n" + "for the rapid movements" + ) ) self.grid3.addWidget(self.fr_rapidlabel, 12, 0) self.cncfeedrate_rapid_entry = LengthEntry() self.grid3.addWidget(self.cncfeedrate_rapid_entry, 12, 1) # Cut over 1st point in path - self.extracut_cb = FCCheckBox('Cut over 1st pt') + self.extracut_cb = FCCheckBox(_tr('Cut over 1st pt')) self.extracut_cb.setToolTip( - "In order to remove possible\n" - "copper leftovers where first cut\n" - "meet with last cut, we generate an\n" - "extended cut over the first cut section." + _tr( + "In order to remove possible\n" + "copper leftovers where first cut\n" + "meet with last cut, we generate an\n" + "extended cut over the first cut section." + ) ) self.grid3.addWidget(self.extracut_cb, 13, 0) # Spindlespeed - spdlabel = QtWidgets.QLabel('Spindle speed:') + spdlabel = QtWidgets.QLabel(_tr('Spindle speed:')) spdlabel.setToolTip( - "Speed of the spindle in RPM (optional).\n" - "If LASER postprocessor is used,\n" - "this value is the power of laser." + _tr( + "Speed of the spindle in RPM (optional).\n" + "If LASER postprocessor is used,\n" + "this value is the power of laser." + ) ) self.grid3.addWidget(spdlabel, 14, 0) self.cncspindlespeed_entry = IntEntry(allow_empty=True) self.grid3.addWidget(self.cncspindlespeed_entry, 14, 1) # Dwell - self.dwell_cb = FCCheckBox('Dwell:') + self.dwell_cb = FCCheckBox(_tr('Dwell:')) self.dwell_cb.setToolTip( - "Pause to allow the spindle to reach its\n" - "speed before cutting." + _tr( + "Pause to allow the spindle to reach its\n" + "speed before cutting." + ) ) self.dwelltime_entry = FCEntry() self.dwelltime_entry.setToolTip( - "Number of milliseconds for spindle to dwell." + _tr( + "Number of milliseconds for spindle to dwell." + ) ) self.grid3.addWidget(self.dwell_cb, 15, 0) self.grid3.addWidget(self.dwelltime_entry, 15, 1) @@ -1232,10 +1292,12 @@ class GeometryObjectUI(ObjectUI): self.ois_dwell_geo = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry]) # postprocessor selection - pp_label = QtWidgets.QLabel("PostProcessor:") + pp_label = QtWidgets.QLabel(_tr("PostProcessor:")) pp_label.setToolTip( - "The Postprocessor file that dictates\n" - "the Machine Code (like GCode, RML, HPGL) output." + _tr( + "The Postprocessor file that dictates\n" + "the Machine Code (like GCode, RML, HPGL) output." + ) ) self.grid3.addWidget(pp_label, 16, 0) self.pp_geometry_name_cb = FCComboBox() @@ -1243,10 +1305,12 @@ class GeometryObjectUI(ObjectUI): self.grid3.addWidget(self.pp_geometry_name_cb, 16, 1) # Probe depth - self.pdepth_label = QtWidgets.QLabel("Probe Z depth:") + self.pdepth_label = QtWidgets.QLabel(_tr("Probe Z depth:")) self.pdepth_label.setToolTip( - "The maximum depth that the probe is allowed\n" - "to probe. Negative value, in current units." + _tr( + "The maximum depth that the probe is allowed\n" + "to probe. Negative value, in current units." + ) ) self.grid3.addWidget(self.pdepth_label, 17, 0) self.pdepth_entry = FCEntry() @@ -1255,9 +1319,11 @@ class GeometryObjectUI(ObjectUI): self.pdepth_entry.setVisible(False) # Probe feedrate - self.feedrate_probe_label = QtWidgets.QLabel("Feedrate Probe:") + self.feedrate_probe_label = QtWidgets.QLabel(_tr("Feedrate Probe:")) self.feedrate_probe_label.setToolTip( - "The feedrate used while the probe is probing." + _tr( + "The feedrate used while the probe is probing." + ) ) self.grid3.addWidget(self.feedrate_probe_label, 18, 0) self.feedrate_probe_entry = FCEntry() @@ -1266,34 +1332,42 @@ class GeometryObjectUI(ObjectUI): self.feedrate_probe_entry.setVisible(False) warning_lbl = QtWidgets.QLabel( - "Add at least one tool in the tool-table.\n" - "Click the header to select all, or Ctrl + LMB\n" - "for custom selection of tools.") + _tr( + "Add at least one tool in the tool-table.\n" + "Click the header to select all, or Ctrl + LMB\n" + "for custom selection of tools." + )) self.grid3.addWidget(warning_lbl, 19, 0, 1, 2) # Button - self.generate_cnc_button = QtWidgets.QPushButton('Generate') + self.generate_cnc_button = QtWidgets.QPushButton(_tr('Generate')) self.generate_cnc_button.setToolTip( - "Generate the CNC Job object." + _tr( + "Generate the CNC Job object." + ) ) self.geo_tools_box.addWidget(self.generate_cnc_button) #------------------------------ # Paint area #------------------------------ - self.paint_label = QtWidgets.QLabel('Paint Area:') + self.paint_label = QtWidgets.QLabel(_tr('Paint Area:')) self.paint_label.setToolTip( - "Creates tool paths to cover the\n" - "whole area of a polygon (remove\n" - "all copper). You will be asked\n" - "to click on the desired polygon." + _tr( + "Creates tool paths to cover the\n" + "whole area of a polygon (remove\n" + "all copper). You will be asked\n" + "to click on the desired polygon." + ) ) self.geo_tools_box.addWidget(self.paint_label) # GO Button - self.paint_tool_button = QtWidgets.QPushButton('Paint Tool') + self.paint_tool_button = QtWidgets.QPushButton(_tr('Paint Tool')) self.paint_tool_button.setToolTip( - "Launch Paint Tool in Tools Tab." + _tr( + "Launch Paint Tool in Tools Tab." + ) ) self.geo_tools_box.addWidget(self.paint_tool_button) @@ -1309,7 +1383,7 @@ class CNCObjectUI(ObjectUI): be placed in ``self.custom_box`` to preserve the layout. """ - ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png', parent=parent) + ObjectUI.__init__(self, title=_tr('CNC Job Object'), icon_file='share/cnc32.png', parent=parent) # Scale and offset ans skew are not available for CNCJob objects. # Hiding from the GUI. @@ -1325,41 +1399,47 @@ class CNCObjectUI(ObjectUI): self.offset_button.hide() ## Plot options - self.plot_options_label = QtWidgets.QLabel("Plot Options:") + self.plot_options_label = QtWidgets.QLabel(_tr("Plot Options:")) self.custom_box.addWidget(self.plot_options_label) - self.cncplot_method_label = QtWidgets.QLabel("Plot kind:") + self.cncplot_method_label = QtWidgets.QLabel(_tr("Plot kind:")) self.cncplot_method_label.setToolTip( - "This selects the kind of geometries on the canvas to plot.\n" - "Those can be either of type 'Travel' which means the moves\n" - "above the work piece or it can be of type 'Cut',\n" - "which means the moves that cut into the material." + _tr( + "This selects the kind of geometries on the canvas to plot.\n" + "Those can be either of type 'Travel' which means the moves\n" + "above the work piece or it can be of type 'Cut',\n" + "which means the moves that cut into the material." + ) ) self.cncplot_method_combo = RadioSet([ - {"label": "All", "value": "all"}, - {"label": "Travel", "value": "travel"}, - {"label": "Cut", "value": "cut"} + {"label": _tr("All"), "value": "all"}, + {"label": _tr("Travel"), "value": "travel"}, + {"label": _tr("Cut"), "value": "cut"} ], stretch=False) ## Object name self.name_hlay = QtWidgets.QHBoxLayout() self.custom_box.addLayout(self.name_hlay) - name_label = QtWidgets.QLabel("Name:") + name_label = QtWidgets.QLabel(_tr("Name:")) self.name_entry = FCEntry() self.name_entry.setFocusPolicy(QtCore.Qt.StrongFocus) self.name_hlay.addWidget(name_label) self.name_hlay.addWidget(self.name_entry) - self.t_distance_label = QtWidgets.QLabel("Travelled dist.:") + self.t_distance_label = QtWidgets.QLabel(_tr("Travelled dist.:")) self.t_distance_label.setToolTip( - "This is the total travelled distance on X-Y plane.\n" - "In current units." + _tr( + "This is the total travelled distance on X-Y plane.\n" + "In current units." + ) ) self.t_distance_entry = FCEntry() self.t_distance_entry.setToolTip( - "This is the total travelled distance on X-Y plane.\n" - "In current units." + _tr( + "This is the total travelled distance on X-Y plane.\n" + "In current units." + ) ) self.units_label = QtWidgets.QLabel() @@ -1385,25 +1465,29 @@ class CNCObjectUI(ObjectUI): self.custom_box.addLayout(hlay) # CNC Tools Table for plot - self.cnc_tools_table_label = QtWidgets.QLabel('CNC Tools Table') + self.cnc_tools_table_label = QtWidgets.QLabel(_tr('CNC Tools Table')) self.cnc_tools_table_label.setToolTip( - "Tools in this CNCJob object used for cutting.\n" - "The tool diameter is used for plotting on canvas.\n" - "The 'Offset' entry will set an offset for the cut.\n" - "'Offset' can be inside, outside, on path (none) and custom.\n" - "'Type' entry is only informative and it allow to know the \n" - "intent of using the current tool. \n" - "It can be Rough(ing), Finish(ing) or Iso(lation).\n" - "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n" - "ball(B), or V-Shaped(V)." + _tr( + "Tools in this CNCJob object used for cutting.\n" + "The tool diameter is used for plotting on canvas.\n" + "The 'Offset' entry will set an offset for the cut.\n" + "'Offset' can be inside, outside, on path (none) and custom.\n" + "'Type' entry is only informative and it allow to know the \n" + "intent of using the current tool. \n" + "It can be Rough(ing), Finish(ing) or Iso(lation).\n" + "The 'Tool type'(TT) can be circular with 1 to 4 teeths(C1..C4),\n" + "ball(B), or V-Shaped(V)." + ) ) hlay.addWidget(self.cnc_tools_table_label) # Plot CB # self.plot_cb = QtWidgets.QCheckBox('Plot') - self.plot_cb = FCCheckBox('Plot Object') + self.plot_cb = FCCheckBox(_tr('Plot Object')) self.plot_cb.setToolTip( - "Plot (show) this object." + _tr( + "Plot (show) this object." + ) ) self.plot_cb.setLayoutDirection(QtCore.Qt.RightToLeft) hlay.addStretch() @@ -1417,33 +1501,36 @@ class CNCObjectUI(ObjectUI): # self.cnc_tools_table.setColumnHidden(3, True) self.cnc_tools_table.setColumnCount(7) self.cnc_tools_table.setColumnWidth(0, 20) - self.cnc_tools_table.setHorizontalHeaderLabels(['#', 'Dia', 'Offset', 'Type', 'TT', '', 'P']) + self.cnc_tools_table.setHorizontalHeaderLabels(['#', _tr('Dia'), _tr('Offset'), _tr('Type'), _tr('TT'), '', + _tr('P')]) self.cnc_tools_table.setColumnHidden(5, True) # stylesheet = "::section{Background-color:rgb(239,239,245)}" # self.cnc_tools_table.horizontalHeader().setStyleSheet(stylesheet) # Update plot button - self.updateplot_button = QtWidgets.QPushButton('Update Plot') + self.updateplot_button = QtWidgets.QPushButton(_tr('Update Plot')) self.updateplot_button.setToolTip( - "Update the plot." + _tr("Update the plot.") ) self.custom_box.addWidget(self.updateplot_button) ################## ## Export G-Code ################## - self.export_gcode_label = QtWidgets.QLabel("Export CNC Code:") + self.export_gcode_label = QtWidgets.QLabel(_tr("Export CNC Code:")) self.export_gcode_label.setToolTip( - "Export and save G-Code to\n" - "make this object to a file." + _tr("Export and save G-Code to\n" + "make this object to a file.") ) self.custom_box.addWidget(self.export_gcode_label) # Prepend text to GCode - prependlabel = QtWidgets.QLabel('Prepend to CNC Code:') + prependlabel = QtWidgets.QLabel(_tr('Prepend to CNC Code:')) prependlabel.setToolTip( - "Type here any G-Code commands you would\n" - "like to add to the beginning of the generated file." + _tr( + "Type here any G-Code commands you would\n" + "like to add to the beginning of the generated file." + ) ) self.custom_box.addWidget(prependlabel) @@ -1451,11 +1538,13 @@ class CNCObjectUI(ObjectUI): self.custom_box.addWidget(self.prepend_text) # Append text to GCode - appendlabel = QtWidgets.QLabel('Append to CNC Code') + appendlabel = QtWidgets.QLabel(_tr('Append to CNC Code')) appendlabel.setToolTip( - "Type here any G-Code commands you would\n" - "like to append to the generated file.\n" - "I.e.: M2 (End of program)" + _tr( + "Type here any G-Code commands you would\n" + "like to append to the generated file.\n" + "I.e.: M2 (End of program)" + ) ) self.custom_box.addWidget(appendlabel) @@ -1470,16 +1559,18 @@ class CNCObjectUI(ObjectUI): self.cnc_frame.setLayout(self.cnc_box) # Toolchange Custom G-Code - self.toolchangelabel = QtWidgets.QLabel('Toolchange G-Code:') + self.toolchangelabel = QtWidgets.QLabel(_tr('Toolchange G-Code:')) self.toolchangelabel.setToolTip( - "Type here any G-Code commands you would\n" - "like to be executed when Toolchange event is encountered.\n" - "This will constitute a Custom Toolchange GCode,\n" - "or a Toolchange Macro.\n" - "The FlatCAM variables are surrounded by '%' symbol.\n\n" - "WARNING: it can be used only with a postprocessor file\n" - "that has 'toolchange_custom' in it's name and this is built\n" - "having as template the 'Toolchange Custom' posprocessor file." + _tr( + "Type here any G-Code commands you would\n" + "like to be executed when Toolchange event is encountered.\n" + "This will constitute a Custom Toolchange GCode,\n" + "or a Toolchange Macro.\n" + "The FlatCAM variables are surrounded by '%' symbol.\n\n" + "WARNING: it can be used only with a postprocessor file\n" + "that has 'toolchange_custom' in it's name and this is built\n" + "having as template the 'Toolchange Custom' posprocessor file." + ) ) self.cnc_box.addWidget(self.toolchangelabel) @@ -1490,10 +1581,12 @@ class CNCObjectUI(ObjectUI): self.cnc_box.addLayout(cnclay) # Toolchange Replacement Enable - self.toolchange_cb = FCCheckBox(label='Use Toolchange Macro') + self.toolchange_cb = FCCheckBox(label=_tr('Use Toolchange Macro')) self.toolchange_cb.setToolTip( - "Check this box if you want to use\n" - "a Custom Toolchange GCode (macro)." + _tr( + "Check this box if you want to use\n" + "a Custom Toolchange GCode (macro)." + ) ) cnclay.addWidget(self.toolchange_cb) @@ -1506,28 +1599,30 @@ class CNCObjectUI(ObjectUI): # Variable list self.tc_variable_combo = FCComboBox() self.tc_variable_combo.setToolTip( - "A list of the FlatCAM variables that can be used\n" - "in the Toolchange event.\n" - "They have to be surrounded by the '%' symbol" + _tr( + "A list of the FlatCAM variables that can be used\n" + "in the Toolchange event.\n" + "They have to be surrounded by the '%' symbol" + ) ) cnclay1.addWidget(self.tc_variable_combo) # Populate the Combo Box - variables = ['Parameters', 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange', + variables = [_tr('Parameters'), 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange', 'z_cut', 'z_move', 'z_depthpercut', 'spindlespeed', 'dwelltime'] self.tc_variable_combo.addItems(variables) - self.tc_variable_combo.setItemData(0, "FlatCAM CNC parameters", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(1, "tool = tool number", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(2, "tooldia = tool diameter", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(3, "t_drills = for Excellon, total number of drills", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(4, "x_toolchange = X coord for Toolchange", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(5, "y_toolchange = Y coord for Toolchange", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(6, "z_toolchange = Z coord for Toolchange", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(7, "z_cut = Z coord for Toolchange", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(8, "z_move = Z coord for Toolchange", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(9, "z_depthpercut = the step value for multidepth cut", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(10, "spindlesspeed = the value for the spindle speed", Qt.ToolTipRole) - self.tc_variable_combo.setItemData(11, "dwelltime = time to dwell to allow the spindle to reach it's set RPM", + self.tc_variable_combo.setItemData(0, _tr("FlatCAM CNC parameters"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(1, _tr("tool = tool number"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(2, _tr("tooldia = tool diameter"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(3, _tr("t_drills = for Excellon, total number of drills"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(4, _tr("x_toolchange = X coord for Toolchange"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(5, _tr("y_toolchange = Y coord for Toolchange"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(6, _tr("z_toolchange = Z coord for Toolchange"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(7, _tr("z_cut = Z coord for Toolchange"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(8, _tr("z_move = Z coord for Toolchange"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(9, _tr("z_depthpercut = the step value for multidepth cut"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(10, _tr("spindlesspeed = the value for the spindle speed"), Qt.ToolTipRole) + self.tc_variable_combo.setItemData(11, _tr("dwelltime = time to dwell to allow the spindle to reach it's set RPM"), Qt.ToolTipRole) cnclay1.addStretch() @@ -1545,17 +1640,21 @@ class CNCObjectUI(ObjectUI): self.custom_box.addLayout(h_lay) # Edit GCode Button - self.modify_gcode_button = QtWidgets.QPushButton('View CNC Code') + self.modify_gcode_button = QtWidgets.QPushButton(_tr('View CNC Code')) self.modify_gcode_button.setToolTip( - "Opens TAB to view/modify/print G-Code\n" - "file." + _tr( + "Opens TAB to view/modify/print G-Code\n" + "file." + ) ) # GO Button - self.export_gcode_button = QtWidgets.QPushButton('Save CNC Code') + self.export_gcode_button = QtWidgets.QPushButton(_tr('Save CNC Code')) self.export_gcode_button.setToolTip( - "Opens dialog to save G-Code\n" - "file." + _tr( + "Opens dialog to save G-Code\n" + "file." + ) ) h_lay.addWidget(self.modify_gcode_button) diff --git a/README.md b/README.md index 6272ad92..2d2a98ff 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing. - finished preparing for internationalization for the files: camlib and objectCollection - fixed tools shortcuts not working anymore due of the new toogle parameter for the .run(). - finished preparing for internationalization for the files: FlatCAMEditor, FlatCAMGUI +- finished preparing for internationalization for the files: FlatCAMObj, ObjectUI 7.03.2019