Просмотр исходного кода

- modified FlatCAMObj.py file to the new string format that will allow easier translations

Marius Stanciu 6 лет назад
Родитель
Сommit
ffbb47dde5
3 измененных файлов с 334 добавлено и 316 удалено
  1. 144 126
      FlatCAMObj.py
  2. 1 0
      README.md
  3. 189 190
      locale_template/strings.pot

+ 144 - 126
FlatCAMObj.py

@@ -1067,7 +1067,8 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
                     else:
                     else:
                         geom = generate_envelope(iso_offset, 0, envelope_iso_type=self.iso_type, follow=follow)
                         geom = generate_envelope(iso_offset, 0, envelope_iso_type=self.iso_type, follow=follow)
                     if geom == 'fail':
                     if geom == 'fail':
-                        app_obj.inform.emit(_("[ERROR_NOTCL] Isolation geometry could not be generated."))
+                        app_obj.inform.emit('[ERROR_NOTCL] %s' %
+                                            _("Isolation geometry could not be generated."))
                         return 'fail'
                         return 'fail'
                     geo_obj.solid_geometry.append(geom)
                     geo_obj.solid_geometry.append(geom)
 
 
@@ -1173,7 +1174,8 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
                     else:
                     else:
                         geom = generate_envelope(offset, 0, envelope_iso_type=self.iso_type, follow=follow)
                         geom = generate_envelope(offset, 0, envelope_iso_type=self.iso_type, follow=follow)
                     if geom == 'fail':
                     if geom == 'fail':
-                        app_obj.inform.emit(_("[ERROR_NOTCL] Isolation geometry could not be generated."))
+                        app_obj.inform.emit('[ERROR_NOTCL] %s' %
+                                            _("Isolation geometry could not be generated."))
                         return 'fail'
                         return 'fail'
 
 
                     geo_obj.solid_geometry = geom
                     geo_obj.solid_geometry = geom
@@ -2359,9 +2361,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
                     self.ui.tools_table.currentItem().setText(
                     self.ui.tools_table.currentItem().setText(
                         self.ui.tools_table.currentItem().text().replace(',', '.'))
                         self.ui.tools_table.currentItem().text().replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_(
-                        "[ERROR_NOTCL] Wrong value format entered, use a number."
-                    ))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _("Wrong value format entered, use a number."))
                     self.ui.tools_table.currentItem().setText(str(self.tool_offset[dia]))
                     self.ui.tools_table.currentItem().setText(str(self.tool_offset[dia]))
                     return
                     return
 
 
@@ -2601,16 +2602,14 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
             log.debug("Tools 'all' and sorted are: %s" % str(tools))
             log.debug("Tools 'all' and sorted are: %s" % str(tools))
 
 
         if len(tools) == 0:
         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('[ERROR_NOTCL] %s' %
+                                 _("Please select one or more tools from the list and try again."))
             return False, "Error: No tools."
             return False, "Error: No tools."
 
 
         for tool in tools:
         for tool in tools:
             if tooldia > self.tools[tool]["C"]:
             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('[ERROR_NOTCL] %s' %
+                                     _("Milling tool for DRILLS is larger than hole size. Cancelled."))
                 return False, "Error: Milling tool is larger than hole."
                 return False, "Error: Milling tool is larger than hole."
 
 
         def geo_init(geo_obj, app_obj):
         def geo_init(geo_obj, app_obj):
@@ -2693,9 +2692,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
             log.debug("Tools 'all' and sorted are: %s" % str(tools))
             log.debug("Tools 'all' and sorted are: %s" % str(tools))
 
 
         if len(tools) == 0:
         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('[ERROR_NOTCL] %s' %
+                                 _("Please select one or more tools from the list and try again."))
             return False, "Error: No tools."
             return False, "Error: No tools."
 
 
         for tool in tools:
         for tool in tools:
@@ -2703,9 +2701,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
             adj_toolstable_tooldia = float('%.4f' % float(tooldia))
             adj_toolstable_tooldia = float('%.4f' % float(tooldia))
             adj_file_tooldia = float('%.4f' % float(self.tools[tool]["C"]))
             adj_file_tooldia = float('%.4f' % float(self.tools[tool]["C"]))
             if adj_toolstable_tooldia > adj_file_tooldia + 0.0001:
             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('[ERROR_NOTCL] %s' %
+                                     _("Milling tool for SLOTS is larger than hole size. Cancelled."))
                 return False, "Error: Milling tool is larger than hole."
                 return False, "Error: Milling tool is larger than hole."
 
 
         def geo_init(geo_obj, app_obj):
         def geo_init(geo_obj, app_obj):
@@ -2816,9 +2813,8 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
             if self.ui.tools_table.rowCount() == 3:
             if self.ui.tools_table.rowCount() == 3:
                 tools.append(self.ui.tools_table.item(0, 0).text())
                 tools.append(self.ui.tools_table.item(0, 0).text())
             else:
             else:
-                self.app.inform.emit(_(
-                    "[ERROR_NOTCL] Please select one or more tools from the list and try again."
-                ))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Please select one or more tools from the list and try again."))
                 return
                 return
 
 
         xmin = self.options['xmin']
         xmin = self.options['xmin']
@@ -2877,8 +2873,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
                 try:
                 try:
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(
-                        _('[ERROR_NOTCL] Wrong value format for self.defaults["z_pdepth"] or self.options["z_pdepth"]'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["z_pdepth"] '
+                                           'or self.options["z_pdepth"]'))
 
 
             try:
             try:
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
@@ -2887,9 +2884,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
                 try:
                 try:
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(
-                        _('[ERROR_NOTCL] Wrong value format for self.defaults["feedrate_probe"] '
-                          'or self.options["feedrate_probe"]'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["feedrate_probe"] or '
+                                           'self.options["feedrate_probe"]'))
 
 
             # There could be more than one drill size...
             # There could be more than one drill size...
             # job_obj.tooldia =   # TODO: duplicate variable!
             # job_obj.tooldia =   # TODO: duplicate variable!
@@ -2944,8 +2941,9 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
         else:
         else:
             coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")]
             coords_xy = [float(eval(coord)) for coord in self.app.defaults["excellon_toolchangexy"].split(",")]
             if len(coords_xy) < 2:
             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('[ERROR] %s' % _("The Toolchange X,Y field in Edit -> Preferences has to be "
+                                                      "in the format (x, y) \n"
+                                                      "but now there is only one value, not two. "))
                 return 'fail'
                 return 'fail'
             coords_xy[0] *= factor
             coords_xy[0] *= factor
             coords_xy[1] *= factor
             coords_xy[1] *= factor
@@ -3640,8 +3638,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                                 self.ui.tool_offset_entry.get_value().replace(',', '.')
                                 self.ui.tool_offset_entry.get_value().replace(',', '.')
                             )
                             )
                         except ValueError:
                         except ValueError:
-                            self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                                   "use a number."))
+                            self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                                 _("Wrong value format entered, use a number."))
                             return
                             return
 
 
     def ui_connect(self):
     def ui_connect(self):
@@ -3771,9 +3769,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
 
 
             if tooldia is None:
             if tooldia is None:
                 self.build_ui()
                 self.build_ui()
-                self.app.inform.emit(_(
-                    "[ERROR_NOTCL] Please enter the desired tool diameter in Float format."
-                ))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Please enter the desired tool diameter in Float format."))
                 return
                 return
 
 
         # construct a list of all 'tooluid' in the self.tools
         # construct a list of all 'tooluid' in the self.tools
@@ -3846,10 +3843,12 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.ser_attrs.append('tools')
         self.ser_attrs.append('tools')
 
 
         if change_message is False:
         if change_message is False:
-            self.app.inform.emit(_("[success] Tool added in Tool Table."))
+            self.app.inform.emit('[success] %s' %
+                                 _("Tool added in Tool Table."))
         else:
         else:
             change_message = False
             change_message = False
-            self.app.inform.emit(_("[WARNING_NOTCL] Default Tool added. Wrong value format entered."))
+            self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                 _("Default Tool added. Wrong value format entered."))
         self.build_ui()
         self.build_ui()
 
 
         # if there is no tool left in the Tools Table, enable the parameters GUI
         # if there is no tool left in the Tools Table, enable the parameters GUI
@@ -3881,7 +3880,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                         max_uid += 1
                         max_uid += 1
                         self.tools[int(max_uid)] = deepcopy(self.tools[tooluid_copy])
                         self.tools[int(max_uid)] = deepcopy(self.tools[tooluid_copy])
                     except AttributeError:
                     except AttributeError:
-                        self.app.inform.emit(_("[WARNING_NOTCL] Failed. Select a tool to copy."))
+                        self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                             _("Failed. Select a tool to copy."))
                         self.build_ui()
                         self.build_ui()
                         return
                         return
                     except Exception as e:
                     except Exception as e:
@@ -3889,7 +3889,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 # deselect the table
                 # deselect the table
                 # self.ui.geo_tools_table.clearSelection()
                 # self.ui.geo_tools_table.clearSelection()
             else:
             else:
-                self.app.inform.emit(_("[WARNING_NOTCL] Failed. Select a tool to copy."))
+                self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                     _("Failed. Select a tool to copy."))
                 self.build_ui()
                 self.build_ui()
                 return
                 return
         else:
         else:
@@ -3916,7 +3917,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.ser_attrs.append('tools')
         self.ser_attrs.append('tools')
 
 
         self.build_ui()
         self.build_ui()
-        self.app.inform.emit(_("[success] Tool was copied in Tool Table."))
+        self.app.inform.emit('[success] %s' %
+                             _("Tool was copied in Tool Table."))
 
 
     def on_tool_edit(self, current_item):
     def on_tool_edit(self, current_item):
 
 
@@ -3930,8 +3932,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             try:
             try:
                 d = float(self.ui.geo_tools_table.item(current_row, 1).text().replace(',', '.'))
                 d = float(self.ui.geo_tools_table.item(current_row, 1).text().replace(',', '.'))
             except ValueError:
             except ValueError:
-                self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                       "use a number."))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Wrong value format entered, use a number."))
                 return
                 return
 
 
         tool_dia = float('%.4f' % d)
         tool_dia = float('%.4f' % d)
@@ -3945,7 +3947,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         except (TypeError, ValueError):
         except (TypeError, ValueError):
             pass
             pass
 
 
-        self.app.inform.emit(_("[success] Tool was edited in Tool Table."))
+        self.app.inform.emit('[success] %s' %
+                             _("Tool was edited in Tool Table."))
         self.build_ui()
         self.build_ui()
 
 
     def on_tool_delete(self, all=None):
     def on_tool_delete(self, all=None):
@@ -3973,7 +3976,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                         self.tools = deepcopy(temp_tools)
                         self.tools = deepcopy(temp_tools)
                         temp_tools.clear()
                         temp_tools.clear()
                     except AttributeError:
                     except AttributeError:
-                        self.app.inform.emit(_("[WARNING_NOTCL] Failed. Select a tool to delete."))
+                        self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                             _("Failed. Select a tool to delete."))
                         self.build_ui()
                         self.build_ui()
                         return
                         return
                     except Exception as e:
                     except Exception as e:
@@ -3981,7 +3985,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 # deselect the table
                 # deselect the table
                 # self.ui.geo_tools_table.clearSelection()
                 # self.ui.geo_tools_table.clearSelection()
             else:
             else:
-                self.app.inform.emit(_("[WARNING_NOTCL] Failed. Select a tool to delete."))
+                self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                     _("Failed. Select a tool to delete."))
                 self.build_ui()
                 self.build_ui()
                 return
                 return
         else:
         else:
@@ -4003,7 +4008,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.ser_attrs.append('tools')
         self.ser_attrs.append('tools')
 
 
         self.build_ui()
         self.build_ui()
-        self.app.inform.emit(_("[success] Tool was deleted in Tool Table."))
+        self.app.inform.emit('[success] %s' %
+                             _("Tool was deleted in Tool Table."))
 
 
         obj_active = self.app.collection.get_active()
         obj_active = self.app.collection.get_active()
         # if the object was MultiGeo and now it has no tool at all (therefore no geometry)
         # if the object was MultiGeo and now it has no tool at all (therefore no geometry)
@@ -4117,8 +4123,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             try:
             try:
                 vdia = float(self.ui.tipdia_entry.get_value().replace(',', '.'))
                 vdia = float(self.ui.tipdia_entry.get_value().replace(',', '.'))
             except ValueError:
             except ValueError:
-                self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                       "use a number."))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Wrong value format entered, use a number."))
                 return
                 return
 
 
         try:
         try:
@@ -4128,8 +4134,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             try:
             try:
                 half_vangle = float(self.ui.tipangle_entry.get_value().replace(',', '.')) / 2
                 half_vangle = float(self.ui.tipangle_entry.get_value().replace(',', '.')) / 2
             except ValueError:
             except ValueError:
-                self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                       "use a number."))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Wrong value format entered, use a number."))
                 return
                 return
 
 
         row = self.ui.geo_tools_table.currentRow()
         row = self.ui.geo_tools_table.currentRow()
@@ -4246,8 +4252,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             try:
             try:
                 offset_value_item = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                 offset_value_item = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
             except ValueError:
             except ValueError:
-                self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                       "use a number."))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Wrong value format entered, use a number."))
                 return
                 return
 
 
         # this new dict will hold the actual useful data, another dict that is the value of key 'data'
         # this new dict will hold the actual useful data, another dict that is the value of key 'data'
@@ -4432,7 +4438,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
 
 
         try:
         try:
             if self.special_group:
             if self.special_group:
-                self.app.inform.emit(_("[WARNING_NOTCL] This Geometry can't be processed because it is %s geometry."
+                self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                     _("This Geometry can't be processed because it is %s geometry."
                 ) % str(self.special_group))
                 ) % str(self.special_group))
                 return
                 return
         except AttributeError:
         except AttributeError:
@@ -4448,8 +4455,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                     try:
                     try:
                         tooldia = float(self.ui.geo_tools_table.item(x.row(), 1).text().replace(',', '.'))
                         tooldia = float(self.ui.geo_tools_table.item(x.row(), 1).text().replace(',', '.'))
                     except ValueError:
                     except ValueError:
-                        self.app.inform.emit(_("[ERROR_NOTCL] Wrong Tool Dia value format entered, "
-                                               "use a number."))
+                        self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                             _("Wrong value format entered, use a number."))
                         return
                         return
                 tooluid = int(self.ui.geo_tools_table.item(x.row(), 5).text())
                 tooluid = int(self.ui.geo_tools_table.item(x.row(), 5).text())
 
 
@@ -4473,7 +4480,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             self.ui.geo_tools_table.clearSelection()
             self.ui.geo_tools_table.clearSelection()
 
 
         else:
         else:
-            self.app.inform.emit(_("[ERROR_NOTCL] Failed. No tool selected in the tool table ..."))
+            self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                 _("Failed. No tool selected in the tool table ..."))
 
 
     def mtool_gen_cncjob(self, segx=None, segy=None, use_thread=True):
     def mtool_gen_cncjob(self, segx=None, segy=None, use_thread=True):
         """
         """
@@ -4509,8 +4517,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             ymax = self.options['ymax']
             ymax = self.options['ymax']
         except Exception as e:
         except Exception as e:
             log.debug("FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s\n" % str(e))
             log.debug("FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s\n" % str(e))
-            msg = _("[ERROR] An internal error has occurred. See shell.\n")
-            msg += _('FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() --> %s') % str(e)
+
+            msg = '[ERROR] %s' % _("An internal error has occurred. See shell.\n")
+            msg += '%s %s' % (_('FlatCAMObj.FlatCAMGeometry.mtool_gen_cncjob() -->'), str(e))
             msg += traceback.format_exc()
             msg += traceback.format_exc()
             self.app.inform.emit(msg)
             self.app.inform.emit(msg)
             return
             return
@@ -4544,8 +4553,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 try:
                 try:
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_('[ERROR_NOTCL] Wrong value format for self.defaults["z_pdepth"] '
-                                           'or self.options["z_pdepth"]'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["z_pdepth"] or '
+                                           'self.options["z_pdepth"]'))
 
 
             try:
             try:
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
@@ -4554,8 +4564,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 try:
                 try:
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_('[ERROR_NOTCL] Wrong value format for self.defaults["feedrate_probe"] '
-                                           'or self.options["feedrate_probe"]'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["feedrate_probe"] or '
+                                           'self.options["feedrate_probe"]'))
 
 
             for tooluid_key in self.sel_tools:
             for tooluid_key in self.sel_tools:
                 tool_cnt += 1
                 tool_cnt += 1
@@ -4651,15 +4662,15 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                         try:
                         try:
                             offset_value = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                             offset_value = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                         except ValueError:
                         except ValueError:
-                            self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                                   "use a number."))
+                            self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                                 _("Wrong value format entered, use a number."))
                             return
                             return
                     if offset_value:
                     if offset_value:
                         tool_offset = float(offset_value)
                         tool_offset = float(offset_value)
                     else:
                     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."))
+                        self.app.inform.emit('[WARNING] %s' % _("Tool Offset is selected in Tool Table but "
+                                                                "no value is provided.\n"
+                                                                "Add a Tool Offset or change the Offset Type."))
                         return
                         return
                 dia_cnc_dict.update({
                 dia_cnc_dict.update({
                     'offset_value': tool_offset
                     'offset_value': tool_offset
@@ -4760,8 +4771,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 try:
                 try:
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_('[ERROR_NOTCL] Wrong value format for self.defaults["z_pdepth"] '
-                                           'or self.options["z_pdepth"]'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["z_pdepth"] or '
+                                           'self.options["z_pdepth"]'))
 
 
             try:
             try:
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
@@ -4770,8 +4782,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 try:
                 try:
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_('[ERROR_NOTCL] Wrong value format for self.defaults["feedrate_probe"] '
-                                           'or self.options["feedrate_probe"]'))
+                    self.app.inform.emit('[ERROR_NOTCL]%s' %
+                                         _(' 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
             # make sure that trying to make a CNCJob from an empty file is not creating an app crash
             if not self.solid_geometry:
             if not self.solid_geometry:
@@ -4780,7 +4793,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                     if self.tools[tooluid_key]['solid_geometry'] is None:
                     if self.tools[tooluid_key]['solid_geometry'] is None:
                         a += 1
                         a += 1
                 if a == len(self.tools):
                 if a == len(self.tools):
-                    self.app.inform.emit(_('[ERROR_NOTCL] Cancelled. Empty file, it has no geometry...'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s...' %
+                                         _('Cancelled. Empty file, it has no geometry'))
                     return 'fail'
                     return 'fail'
 
 
             for tooluid_key in self.sel_tools:
             for tooluid_key in self.sel_tools:
@@ -4887,13 +4901,14 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                         try:
                         try:
                             offset_value = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                             offset_value = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                         except ValueError:
                         except ValueError:
-                            self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
-                                                   "use a number."))
+                            self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                                 _("Wrong value format entered, use a number."))
                             return
                             return
                     if offset_value:
                     if offset_value:
                         tool_offset = float(offset_value)
                         tool_offset = float(offset_value)
                     else:
                     else:
-                        self.app.inform.emit(_("[WARNING] Tool Offset is selected in Tool Table but "
+                        self.app.inform.emit('[WARNING] %s' %
+                                             _("Tool Offset is selected in Tool Table but "
                                                "no value is provided.\n"
                                                "no value is provided.\n"
                                                "Add a Tool Offset or change the Offset Type."))
                                                "Add a Tool Offset or change the Offset Type."))
                         return
                         return
@@ -4969,12 +4984,14 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 if self.solid_geometry:
                 if self.solid_geometry:
                     with self.app.proc_container.new(_("Generating CNC Code")):
                     with self.app.proc_container.new(_("Generating CNC Code")):
                         if app_obj.new_object("cncjob", outname, job_init_single_geometry) != 'fail':
                         if app_obj.new_object("cncjob", outname, job_init_single_geometry) != 'fail':
-                            app_obj.inform.emit("[success] CNCjob created: %s" % outname)
+                            app_obj.inform.emit('[success] %s: %s' %
+                                                (_("CNCjob created")), outname)
                             app_obj.progress.emit(100)
                             app_obj.progress.emit(100)
                 else:
                 else:
                     with self.app.proc_container.new(_("Generating CNC Code")):
                     with self.app.proc_container.new(_("Generating CNC Code")):
                         if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail':
                         if app_obj.new_object("cncjob", outname, job_init_multi_geometry) != 'fail':
-                            app_obj.inform.emit("[success] CNCjob created: %s" % outname)
+                            app_obj.inform.emit('[success] %s: %s' %
+                                                (_("CNCjob created")), outname)
                             app_obj.progress.emit(100)
                             app_obj.progress.emit(100)
 
 
             # Create a promise with the name
             # Create a promise with the name
@@ -5077,8 +5094,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 try:
                 try:
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                     job_obj.z_pdepth = float(self.options["z_pdepth"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_('[ERROR_NOTCL] Wrong value format for self.defaults["z_pdepth"] '
-                                           'or self.options["z_pdepth"]'))
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["z_pdepth"] or '
+                                           'self.options["z_pdepth"]'))
 
 
             try:
             try:
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
                 job_obj.feedrate_probe = float(self.options["feedrate_probe"])
@@ -5087,7 +5105,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 try:
                 try:
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                     job_obj.feedrate_rapid = float(self.options["feedrate_probe"].replace(',', '.'))
                 except ValueError:
                 except ValueError:
-                    self.app.inform.emit(_('[ERROR_NOTCL] Wrong value format for self.defaults["feedrate_probe"] '
+                    self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                         _('Wrong value format for self.defaults["feedrate_probe"] '
                                            'or self.options["feedrate_probe"]'))
                                            'or self.options["feedrate_probe"]'))
 
 
             job_obj.options['xmin'] = self.options['xmin']
             job_obj.options['xmin'] = self.options['xmin']
@@ -5113,7 +5132,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             # source of gcode
             # source of gcode
             job_obj.toolchange_xy_type = "geometry"
             job_obj.toolchange_xy_type = "geometry"
             job_obj.gcode_parse()
             job_obj.gcode_parse()
-            self.app.inform.emit(_("[success] Finished G-Code processing..."))
+            self.app.inform.emit('[success] %s' %
+                                 _("Finished G-Code processing..."))
 
 
             app_obj.progress.emit(80)
             app_obj.progress.emit(80)
 
 
@@ -5122,7 +5142,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             def job_thread(app_obj):
             def job_thread(app_obj):
                 with self.app.proc_container.new(_("Generating CNC Code")):
                 with self.app.proc_container.new(_("Generating CNC Code")):
                     app_obj.new_object("cncjob", outname, job_init)
                     app_obj.new_object("cncjob", outname, job_init)
-                    app_obj.inform.emit("[success] CNCjob created: %s" % outname)
+                    app_obj.inform.emit('[success] %s: %s' %
+                                        (_("CNCjob created")), outname)
                     app_obj.progress.emit(100)
                     app_obj.progress.emit(100)
 
 
             # Create a promise with the name
             # Create a promise with the name
@@ -5153,8 +5174,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         try:
         try:
             xfactor = float(xfactor)
             xfactor = float(xfactor)
         except Exception as e:
         except Exception as e:
-            self.app.inform.emit(_(
-                "[ERROR_NOTCL] Scale factor has to be a number: integer or float."))
+            self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                 _("Scale factor has to be a number: integer or float."))
             return
             return
 
 
         if yfactor is None:
         if yfactor is None:
@@ -5163,7 +5184,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             try:
             try:
                 yfactor = float(yfactor)
                 yfactor = float(yfactor)
             except Exception as e:
             except Exception as e:
-                self.app.inform.emit(_("[ERROR_NOTCL] Scale factor has to be a number: integer or float."))
+                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                     _("Scale factor has to be a number: integer or float."))
                 return
                 return
 
 
         if point is None:
         if point is None:
@@ -5253,9 +5275,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         try:
         try:
             dx, dy = vect
             dx, dy = vect
         except TypeError:
         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('[ERROR_NOTCL] %s' %
+                                 _("An (x,y) pair of values are needed. "
+                                   "Probable you entered only one value in the Offset field."
             ))
             ))
             return
             return
 
 
@@ -5336,9 +5358,10 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         else:
         else:
             coords_xy = [float(eval(coord)) for coord in self.app.defaults["geometry_toolchangexy"].split(",")]
             coords_xy = [float(eval(coord)) for coord in self.app.defaults["geometry_toolchangexy"].split(",")]
             if len(coords_xy) < 2:
             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('[ERROR] %s' %
+                                     _("The Toolchange X,Y field in Edit -> Preferences "
+                                       "has to be in the format (x, y)\n"
+                                       "but now there is only one value, not two."
                 ))
                 ))
                 return 'fail'
                 return 'fail'
             coords_xy[0] *= factor
             coords_xy[0] *= factor
@@ -5376,10 +5399,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                             try:
                             try:
                                 custom_offset = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                                 custom_offset = float(self.ui.tool_offset_entry.get_value().replace(',', '.'))
                             except ValueError:
                             except ValueError:
-                                self.app.inform.emit(_(
-                                    "[ERROR_NOTCL] Wrong value format entered, "
-                                    "use a number."
-                                ))
+                                self.app.inform.emit('[ERROR_NOTCL] %s' %
+                                                     _("Wrong value format entered, use a number."))
                                 return
                                 return
                         except TypeError:
                         except TypeError:
                             pass
                             pass
@@ -5889,8 +5910,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         filename = str(filename)
         filename = str(filename)
 
 
         if filename == '':
         if filename == '':
-            self.app.inform.emit(_(
-                "[WARNING_NOTCL] Export Machine Code cancelled ..."))
+            self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                 _("Export Machine Code cancelled ..."))
             return
             return
 
 
         new_name = os.path.split(str(filename))[1].rpartition('.')[0]
         new_name = os.path.split(str(filename))[1].rpartition('.')[0]
@@ -5907,7 +5928,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
         if self.app.defaults["global_open_style"] is False:
         if self.app.defaults["global_open_style"] is False:
             self.app.file_opened.emit("gcode", filename)
             self.app.file_opened.emit("gcode", filename)
         self.app.file_saved.emit("gcode", filename)
         self.app.file_saved.emit("gcode", filename)
-        self.app.inform.emit(_("[success] Machine Code file saved to: %s") % filename)
+        self.app.inform.emit('[success] %s: %s' %
+                             (_("Machine Code file saved to"), filename))
 
 
     def on_edit_code_click(self, *args):
     def on_edit_code_click(self, *args):
 
 
@@ -5930,14 +5952,16 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                 self.app.ui.code_editor.append(proc_line)
                 self.app.ui.code_editor.append(proc_line)
         except Exception as e:
         except Exception as e:
             log.debug('FlatCAMCNNJob.on_edit_code_click() -->%s' % str(e))
             log.debug('FlatCAMCNNJob.on_edit_code_click() -->%s' % str(e))
-            self.app.inform.emit(_('[ERROR] FlatCAMCNNJob.on_edit_code_click() -->%s') % str(e))
+            self.app.inform.emit('[ERROR] %s %s' %
+                                 (_('FlatCAMCNNJob.on_edit_code_click() -->'), str(e)))
             return
             return
 
 
         self.app.ui.code_editor.moveCursor(QtGui.QTextCursor.Start)
         self.app.ui.code_editor.moveCursor(QtGui.QTextCursor.Start)
 
 
         self.app.handleTextChanged()
         self.app.handleTextChanged()
         self.app.ui.show()
         self.app.ui.show()
-        self.app.inform.emit(_('[success] Loaded Machine Code into Code Editor ...'))
+        self.app.inform.emit('[success] %s...' %
+                             _('Loaded Machine Code into Code Editor'))
 
 
     def gcode_header(self):
     def gcode_header(self):
         log.debug("FlatCAMCNCJob.gcode_header()")
         log.debug("FlatCAMCNCJob.gcode_header()")
@@ -6048,8 +6072,10 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
 
 
         try:
         try:
             if self.special_group:
             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('[WARNING_NOTCL] %s %s %s.' %
+                                     (_("This CNCJob object can't be processed because it is a"),
+                                      str(self.special_group),
+                                      _("CNCJob object")))
                 return 'fail'
                 return 'fail'
         except AttributeError:
         except AttributeError:
             pass
             pass
@@ -6100,9 +6126,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
 
 
             # if it did not find 'G20' and it did not find 'G21' then there is an error and return
             # if it did not find 'G20' and it did not find 'G21' then there is an error and return
             if g_idx == -1:
             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('[ERROR_NOTCL] %s' %
+                                     _("G-code does not have a units code: either G20 or G21"))
                 return
                 return
 
 
             g = gcode[:g_idx] + preamble + '\n' + gcode[g_idx:] + postamble + self.gcode_footer()
             g = gcode[:g_idx] + preamble + '\n' + gcode[g_idx:] + postamble + self.gcode_footer()
@@ -6113,16 +6138,14 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
             if 'M6' in g:
             if 'M6' in g:
                 m6_code = self.parse_custom_toolchange_code(self.ui.toolchange_text.get_value())
                 m6_code = self.parse_custom_toolchange_code(self.ui.toolchange_text.get_value())
                 if m6_code is None or m6_code == '':
                 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('[ERROR_NOTCL] %s' %
+                                         _("Cancelled. The Toolchange Custom code is enabled but it's empty."
                     ))
                     ))
                     return 'fail'
                     return 'fail'
 
 
                 g = g.replace('M6', m6_code)
                 g = g.replace('M6', m6_code)
-                self.app.inform.emit(_(
-                    "[success] Toolchange G-code was replaced by a custom code."
-                ))
+                self.app.inform.emit('[success] %s' %
+                                     _("Toolchange G-code was replaced by a custom code."))
 
 
         # lines = StringIO(self.gcode)
         # lines = StringIO(self.gcode)
         lines = StringIO(g)
         lines = StringIO(g)
@@ -6134,12 +6157,12 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                     for line in lines:
                     for line in lines:
                         f.write(line)
                         f.write(line)
             except FileNotFoundError:
             except FileNotFoundError:
-                self.app.inform.emit(_(
-                    "[WARNING_NOTCL] No such file or directory"
-                ))
+                self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                     _("No such file or directory"))
                 return
                 return
             except PermissionError:
             except PermissionError:
-                self.app.inform.emit(_("[WARNING] Permission denied, saving not possible.\n"
+                self.app.inform.emit('[WARNING] %s' %
+                                     _("Permission denied, saving not possible.\n"
                                        "Most likely another app is holding the file open and not accessible."))
                                        "Most likely another app is holding the file open and not accessible."))
                 return 'fail'
                 return 'fail'
         elif to_file is False:
         elif to_file is False:
@@ -6148,7 +6171,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                 self.app.file_opened.emit("cncjob", filename)
                 self.app.file_opened.emit("cncjob", filename)
             self.app.file_saved.emit("cncjob", filename)
             self.app.file_saved.emit("cncjob", filename)
 
 
-            self.app.inform.emit("[success] Saved to: " + filename)
+            self.app.inform.emit('[success] %s: %s' %
+                                 (_("Saved to"), filename))
         else:
         else:
             return lines
             return lines
 
 
@@ -6157,10 +6181,8 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
             if 'toolchange_custom' not in str(self.options['ppname_e']).lower():
             if 'toolchange_custom' not in str(self.options['ppname_e']).lower():
                 if self.ui.toolchange_cb.get_value():
                 if self.ui.toolchange_cb.get_value():
                     self.ui.toolchange_cb.set_value(False)
                     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'"
-                        ))
+                    self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                         _("The used postprocessor file has to have in it's name: 'toolchange_custom'"))
         except KeyError:
         except KeyError:
             try:
             try:
                 for key in self.cnc_tools:
                 for key in self.cnc_tools:
@@ -6169,16 +6191,12 @@ class FlatCAMCNCjob(FlatCAMObj, CNCjob):
                         print(ppg)
                         print(ppg)
                         if self.ui.toolchange_cb.get_value():
                         if self.ui.toolchange_cb.get_value():
                             self.ui.toolchange_cb.set_value(False)
                             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'"
-                                ))
+                            self.app.inform.emit('[WARNING_NOTCL] %s' %
+                                                 _("The used postprocessor file has to have in it's name: "
+                                                   "'toolchange_custom'"))
             except KeyError:
             except KeyError:
-                self.app.inform.emit(
-                    _(
-                        "[ERROR] There is no postprocessor file."
-                    ))
+                self.app.inform.emit('[ERROR] %s' %
+                                     _("There is no postprocessor file."))
 
 
     def get_gcode(self, preamble='', postamble=''):
     def get_gcode(self, preamble='', postamble=''):
         # we need this to be able get_gcode separatelly for shell command export_gcode
         # we need this to be able get_gcode separatelly for shell command export_gcode

+ 1 - 0
README.md

@@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing.
 - added for NCC Tool and Paint Tool a setting in the Preferences -> Tools --> (NCC Tool/ Paint Tool) that can set a progressive plotting (plot shapes as they are processed)
 - added for NCC Tool and Paint Tool a setting in the Preferences -> Tools --> (NCC Tool/ Paint Tool) that can set a progressive plotting (plot shapes as they are processed)
 - some fixes in Paint Tool when done over the Gerber objects in case that the progressive plotting is selected
 - some fixes in Paint Tool when done over the Gerber objects in case that the progressive plotting is selected
 - some fixes in Gerber isolation in case that the progressive plotting is selected; added a 'Buffer solid geometry' button shown only when progressive plotting for Gerber object is selected. It will buffer the entire geometry of the object and plot it, in a threaded way.
 - some fixes in Gerber isolation in case that the progressive plotting is selected; added a 'Buffer solid geometry' button shown only when progressive plotting for Gerber object is selected. It will buffer the entire geometry of the object and plot it, in a threaded way.
+- modified FlatCAMObj.py file to the new string format that will allow easier translations
 
 
 8.09.2019
 8.09.2019
 
 

Разница между файлами не показана из-за своего большого размера
+ 189 - 190
locale_template/strings.pot


Некоторые файлы не были показаны из-за большого количества измененных файлов