diff --git a/ObjectCollection.py b/ObjectCollection.py
index 78fe321d..090e6c11 100644
--- a/ObjectCollection.py
+++ b/ObjectCollection.py
@@ -76,7 +76,7 @@ class KeySensitiveListView(QtWidgets.QTreeView):
# file drop from outside application
if drop_indicator == QtWidgets.QAbstractItemView.OnItem:
if self.filename == "":
- self.app.inform.emit("Open cancelled.")
+ self.app.inform.emit(_tr("Open cancelled."))
else:
if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
self.app.worker_task.emit({'fcn': self.app.open_gerber,
@@ -398,7 +398,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
"setData() --> Could not remove the old object name from auto-completer model list")
obj.build_ui()
- self.app.inform.emit("Object renamed from %s to %s" % (old_name, new_name))
+ self.app.inform.emit(_tr("Object renamed from %s to %s") % (old_name, new_name))
return True
@@ -692,16 +692,16 @@ class ObjectCollection(QtCore.QAbstractItemModel):
obj = current.indexes()[0].internalPointer().obj
if obj.kind == 'gerber':
- self.app.inform.emit('[selected]%s selected' %
+ self.app.inform.emit(_tr('[selected]%s selected') %
('green', str(obj.options['name'])))
elif obj.kind == 'excellon':
- self.app.inform.emit('[selected]%s selected' %
+ self.app.inform.emit(_tr('[selected]%s selected') %
('brown', str(obj.options['name'])))
elif obj.kind == 'cncjob':
- self.app.inform.emit('[selected]%s selected' %
+ self.app.inform.emit(_tr('[selected]%s selected') %
('blue', str(obj.options['name'])))
elif obj.kind == 'geometry':
- self.app.inform.emit('[selected]%s selected' %
+ self.app.inform.emit(_tr('[selected]%s selected') %
('red', str(obj.options['name'])))
except IndexError:
@@ -732,7 +732,7 @@ class ObjectCollection(QtCore.QAbstractItemModel):
try:
a_idx.build_ui()
except Exception as e:
- self.app.inform.emit("[ERROR] Cause of error: %s" % str(e))
+ self.app.inform.emit(_tr("[ERROR] Cause of error: %s") % str(e))
raise
def get_list(self):
diff --git a/README.md b/README.md
index 83cb10eb..dd6a418f 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ CAD program, and create G-Code for Isolation routing.
- fixed issue when doing th CTRL (or SHIFT) + LMB, the focus is automatically moved to Project Tab
- further work in internationalization, added a fallback to English language in case there is no translation for a string
- fix for issue #262: when doing Edit-> Save & Close Editor on a Geometry that is not generated through first entering into an Editor, the geometry disappear
--
+- finished preparing for internationalization for the files: camlib and objectColletion
7.03.2019
diff --git a/camlib.py b/camlib.py
index b54b67fc..13b26851 100644
--- a/camlib.py
+++ b/camlib.py
@@ -206,7 +206,7 @@ class Geometry(object):
if isinstance(self.solid_geometry, list):
return len(self.solid_geometry) == 0
- self.app.inform.emit("[ERROR_NOTCL] self.solid_geometry is neither BaseGeometry or list.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] self.solid_geometry is neither BaseGeometry or list."))
return
def subtract_polygon(self, points):
@@ -1393,9 +1393,9 @@ class Geometry(object):
self.tools[tool]['solid_geometry'] = mirror_geom(self.tools[tool]['solid_geometry'])
else:
self.solid_geometry = mirror_geom(self.solid_geometry)
- self.app.inform.emit('[success]Object was mirrored ...')
+ self.app.inform.emit(_tr('[success]Object was mirrored ...'))
except AttributeError:
- self.app.inform.emit("[ERROR_NOTCL] Failed to mirror. No object selected")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Failed to mirror. No object selected"))
def rotate(self, angle, point):
"""
@@ -1431,9 +1431,9 @@ class Geometry(object):
self.tools[tool]['solid_geometry'] = rotate_geom(self.tools[tool]['solid_geometry'])
else:
self.solid_geometry = rotate_geom(self.solid_geometry)
- self.app.inform.emit('[success]Object was rotated ...')
+ self.app.inform.emit(_tr('[success]Object was rotated ...'))
except AttributeError:
- self.app.inform.emit("[ERROR_NOTCL] Failed to rotate. No object selected")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Failed to rotate. No object selected"))
def skew(self, angle_x, angle_y, point):
"""
@@ -1467,9 +1467,9 @@ class Geometry(object):
self.tools[tool]['solid_geometry'] = skew_geom(self.tools[tool]['solid_geometry'])
else:
self.solid_geometry = skew_geom(self.solid_geometry)
- self.app.inform.emit('[success]Object was skewed ...')
+ self.app.inform.emit(_tr('[success]Object was skewed ...'))
except AttributeError:
- self.app.inform.emit("[ERROR_NOTCL] Failed to skew. No object selected")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Failed to skew. No object selected"))
# if type(self.solid_geometry) == list:
# self.solid_geometry = [affinity.skew(g, angle_x, angle_y, origin=(px, py))
@@ -2645,8 +2645,8 @@ class Gerber (Geometry):
pass
last_path_aperture = current_aperture
else:
- self.app.inform.emit("[WARNING] Coordinates missing, line ignored: %s" % str(gline))
- self.app.inform.emit("[WARNING_NOTCL] GERBER file might be CORRUPT. Check the file !!!")
+ self.app.inform.emit(_tr("[WARNING] Coordinates missing, line ignored: %s") % str(gline))
+ self.app.inform.emit(_tr("[WARNING_NOTCL] GERBER file might be CORRUPT. Check the file !!!"))
elif current_operation_code == 2:
if len(path) > 1:
@@ -2675,9 +2675,9 @@ class Gerber (Geometry):
geo = Polygon(path)
except ValueError:
log.warning("Problem %s %s" % (gline, line_num))
- self.app.inform.emit("[ERROR] Region does not have enough points. "
+ self.app.inform.emit(_tr("[ERROR] Region does not have enough points. "
"File will be processed but there are parser errors. "
- "Line number: %s" % str(line_num))
+ "Line number: %s") % str(line_num))
else:
if last_path_aperture is None:
log.warning("No aperture defined for curent path. (%d)" % line_num)
@@ -2705,8 +2705,8 @@ class Gerber (Geometry):
if linear_x is not None and linear_y is not None:
path = [[linear_x, linear_y]] # Start new path
else:
- self.app.inform.emit("[WARNING] Coordinates missing, line ignored: %s" % str(gline))
- self.app.inform.emit("[WARNING_NOTCL] GERBER file might be CORRUPT. Check the file !!!")
+ self.app.inform.emit(_tr("[WARNING] Coordinates missing, line ignored: %s") % str(gline))
+ self.app.inform.emit(_tr("[WARNING_NOTCL] GERBER file might be CORRUPT. Check the file !!!"))
# Flash
# Not allowed in region mode.
@@ -3029,7 +3029,7 @@ class Gerber (Geometry):
log.error("Gerber PARSING FAILED. Line %d: %s" % (line_num, gline))
loc = 'Gerber Line #%d Gerber Line Content: %s\n' % (line_num, gline) + repr(err)
- self.app.inform.emit("[ERROR]Gerber Parser ERROR.\n%s:" % loc)
+ self.app.inform.emit(_tr("[ERROR]Gerber Parser ERROR.\n%s:") % loc)
@staticmethod
def create_flash_geometry(location, aperture, steps_per_circle=None):
@@ -3207,7 +3207,7 @@ class Gerber (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:
@@ -3216,7 +3216,7 @@ class Gerber (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:
@@ -3245,7 +3245,7 @@ class Gerber (Geometry):
except Exception as e:
log.debug('FlatCAMGeometry.scale() --> %s' % str(e))
- self.app.inform.emit("[success]Gerber Scale done.")
+ self.app.inform.emit(_tr("[success]Gerber Scale done."))
## solid_geometry ???
@@ -3278,8 +3278,8 @@ class Gerber (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 offset_geom(obj):
@@ -3302,7 +3302,7 @@ class Gerber (Geometry):
except Exception as e:
log.debug('FlatCAMGeometry.offset() --> %s' % str(e))
- self.app.inform.emit("[success]Gerber Offset done.")
+ self.app.inform.emit(_tr("[success]Gerber Offset done."))
def mirror(self, axis, point):
"""
@@ -3678,7 +3678,7 @@ class Excellon(Geometry):
# and we need to exit from here
if self.detect_gcode_re.search(eline):
log.warning("This is GCODE mark: %s" % eline)
- self.app.inform.emit('[ERROR_NOTCL] This is GCODE mark: %s' % eline)
+ self.app.inform.emit(_tr('[ERROR_NOTCL] This is GCODE mark: %s') % eline)
return
# Header Begin (M48) #
@@ -4207,8 +4207,8 @@ class Excellon(Geometry):
log.info("Zeros: %s, Units %s." % (self.zeros, self.units))
except Exception as e:
log.error("Excellon PARSING FAILED. Line %d: %s" % (line_num, eline))
- msg = "[ERROR_NOTCL] An internal error has ocurred. See shell.\n"
- msg += '[ERROR] Excellon Parser error.\nParsing Failed. Line %d: %s\n' % (line_num, eline)
+ msg = _tr("[ERROR_NOTCL] An internal error has ocurred. See shell.\n")
+ msg += _tr('[ERROR] Excellon Parser error.\nParsing Failed. Line %d: %s\n') % (line_num, eline)
msg += traceback.format_exc()
self.app.inform.emit(msg)
@@ -4285,9 +4285,9 @@ class Excellon(Geometry):
for drill in self.drills:
# poly = drill['point'].buffer(self.tools[drill['tool']]["C"]/2.0)
if drill['tool'] is '':
- self.app.inform.emit("[WARNING] Excellon.create_geometry() -> a drill location was skipped "
+ self.app.inform.emit(_tr("[WARNING] Excellon.create_geometry() -> a drill location was skipped "
"due of not having a tool associated.\n"
- "Check the resulting GCode.")
+ "Check the resulting GCode."))
log.debug("Excellon.create_geometry() -> a drill location was skipped "
"due of not having a tool associated")
continue
@@ -4821,7 +4821,7 @@ class CNCjob(Geometry):
try:
value = getattr(self, command)
except AttributeError:
- self.app.inform.emit("[ERROR] There is no such parameter: %s" % str(match))
+ self.app.inform.emit(_tr("[ERROR] There is no such parameter: %s") % str(match))
log.debug("CNCJob.parse_custom_toolchange_code() --> AttributeError ")
return 'fail'
text = text.replace(match, str(value))
@@ -4886,15 +4886,15 @@ class CNCjob(Geometry):
:rtype: None
"""
if drillz > 0:
- self.app.inform.emit("[WARNING] The Cut Z parameter has positive value. "
+ self.app.inform.emit(_tr("[WARNING] The Cut Z parameter has positive value. "
"It is the depth value to drill into material.\n"
"The Cut Z parameter needs to have a negative value, assuming it is a typo "
"therefore the app will convert the value to negative. "
- "Check the resulting CNC code (Gcode etc).")
+ "Check the resulting CNC code (Gcode etc)."))
self.z_cut = -drillz
elif drillz == 0:
- self.app.inform.emit("[WARNING] The Cut Z parameter is zero. "
- "There will be no cut, skipping %s file" % exobj.options['name'])
+ self.app.inform.emit(_tr("[WARNING] The Cut Z parameter is zero. "
+ "There will be no cut, skipping %s file") % exobj.options['name'])
return 'fail'
else:
self.z_cut = drillz
@@ -4907,8 +4907,8 @@ class CNCjob(Geometry):
else:
self.xy_toolchange = [float(eval(a)) for a in toolchangexy.split(",")]
if len(self.xy_toolchange) < 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'
except Exception as e:
log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> %s" % str(e))
@@ -5109,7 +5109,7 @@ class CNCjob(Geometry):
else:
log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
"The loaded Excellon file has no drills ...")
- self.app.inform.emit('[ERROR_NOTCL]The loaded Excellon file has no drills ...')
+ self.app.inform.emit(_tr('[ERROR_NOTCL]The loaded Excellon file has no drills ...'))
return 'fail'
log.debug("The total travel distance with OR-TOOLS Metaheuristics is: %s" % str(measured_distance))
@@ -5199,12 +5199,12 @@ class CNCjob(Geometry):
else:
log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
"The loaded Excellon file has no drills ...")
- self.app.inform.emit('[ERROR_NOTCL]The loaded Excellon file has no drills ...')
+ self.app.inform.emit(_tr('[ERROR_NOTCL]The loaded Excellon file has no drills ...'))
return 'fail'
log.debug("The total travel distance with OR-TOOLS Basic Algorithm is: %s" % str(measured_distance))
else:
- self.app.inform.emit("[ERROR_NOTCL] Wrong optimization type selected.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Wrong optimization type selected."))
return 'fail'
else:
log.debug("Using Travelling Salesman drill path optimization.")
@@ -5250,7 +5250,7 @@ class CNCjob(Geometry):
else:
log.debug("camlib.CNCJob.generate_from_excellon_by_tool() --> "
"The loaded Excellon file has no drills ...")
- self.app.inform.emit('[ERROR_NOTCL]The loaded Excellon file has no drills ...')
+ self.app.inform.emit(_tr('[ERROR_NOTCL]The loaded Excellon file has no drills ...'))
return 'fail'
log.debug("The total travel distance with Travelling Salesman Algorithm is: %s" % str(measured_distance))
@@ -5338,8 +5338,8 @@ class CNCjob(Geometry):
else:
self.xy_toolchange = [float(eval(a)) for a in toolchangexy.split(",")]
if len(self.xy_toolchange) < 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'
except Exception as e:
log.debug("camlib.CNCJob.generate_from_multitool_geometry() --> %s" % str(e))
@@ -5349,36 +5349,36 @@ class CNCjob(Geometry):
self.f_plunge = self.app.defaults["geometry_f_plunge"]
if self.z_cut is None:
- self.app.inform.emit("[ERROR_NOTCL] Cut_Z parameter is None or zero. Most likely a bad combinations of "
- "other parameters.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Cut_Z parameter is None or zero. Most likely a bad combinations of "
+ "other parameters."))
return 'fail'
if self.z_cut > 0:
- self.app.inform.emit("[WARNING] The Cut Z parameter has positive value. "
+ self.app.inform.emit(_tr("[WARNING] The Cut Z parameter has positive value. "
"It is the depth value to cut into material.\n"
"The Cut Z parameter needs to have a negative value, assuming it is a typo "
"therefore the app will convert the value to negative."
- "Check the resulting CNC code (Gcode etc).")
+ "Check the resulting CNC code (Gcode etc)."))
self.z_cut = -self.z_cut
elif self.z_cut == 0:
- self.app.inform.emit("[WARNING] The Cut Z parameter is zero. "
- "There will be no cut, skipping %s file" % self.options['name'])
+ self.app.inform.emit(_tr("[WARNING] The Cut Z parameter is zero. "
+ "There will be no cut, skipping %s file") % self.options['name'])
return 'fail'
if self.z_move is None:
- self.app.inform.emit("[ERROR_NOTCL] Travel Z parameter is None or zero.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Travel Z parameter is None or zero."))
return 'fail'
if self.z_move < 0:
- self.app.inform.emit("[WARNING] The Travel Z parameter has negative value. "
+ self.app.inform.emit(_tr("[WARNING] The Travel Z parameter has negative value. "
"It is the height value to travel between cuts.\n"
"The Z Travel parameter needs to have a positive value, assuming it is a typo "
"therefore the app will convert the value to positive."
- "Check the resulting CNC code (Gcode etc).")
+ "Check the resulting CNC code (Gcode etc)."))
self.z_move = -self.z_move
elif self.z_move == 0:
- self.app.inform.emit("[WARNING] The Z Travel parameter is zero. "
- "This is dangerous, skipping %s file" % self.options['name'])
+ self.app.inform.emit(_tr("[WARNING] The Z Travel parameter is zero. "
+ "This is dangerous, skipping %s file") % self.options['name'])
return 'fail'
## Index first and last points in paths
@@ -5507,14 +5507,14 @@ class CNCjob(Geometry):
"""
if not isinstance(geometry, Geometry):
- self.app.inform.emit("[ERROR]Expected a Geometry, got %s" % type(geometry))
+ self.app.inform.emit(_tr("[ERROR]Expected a Geometry, got %s") % type(geometry))
return 'fail'
log.debug("Generate_from_geometry_2()")
# if solid_geometry is empty raise an exception
if not geometry.solid_geometry:
- self.app.inform.emit("[ERROR_NOTCL]Trying to generate a CNC Job "
- "from a Geometry object without solid_geometry.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL]Trying to generate a CNC Job "
+ "from a Geometry object without solid_geometry."))
temp_solid_geometry = []
@@ -5552,9 +5552,9 @@ class CNCjob(Geometry):
# if the offset is less than half of the total length or less than half of the total width of the
# solid geometry it's obvious we can't do the offset
if -offset > ((c - a) / 2) or -offset > ((d - b) / 2):
- self.app.inform.emit("[ERROR_NOTCL]The Tool Offset value is too negative to use "
+ self.app.inform.emit(_tr("[ERROR_NOTCL]The Tool Offset value is too negative to use "
"for the current_geometry.\n"
- "Raise the value (in module) and try again.")
+ "Raise the value (in module) and try again."))
return 'fail'
# hack: make offset smaller by 0.0000000001 which is insignificant difference but allow the job
# to continue
@@ -5609,8 +5609,8 @@ class CNCjob(Geometry):
else:
self.xy_toolchange = [float(eval(a)) for a in toolchangexy.split(",")]
if len(self.xy_toolchange) < 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'
except Exception as e:
log.debug("camlib.CNCJob.generate_from_geometry_2() --> %s" % str(e))
@@ -5620,36 +5620,36 @@ class CNCjob(Geometry):
self.f_plunge = self.app.defaults["geometry_f_plunge"]
if self.z_cut is None:
- self.app.inform.emit("[ERROR_NOTCL] Cut_Z parameter is None or zero. Most likely a bad combinations of "
- "other parameters.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Cut_Z parameter is None or zero. Most likely a bad combinations of "
+ "other parameters."))
return 'fail'
if self.z_cut > 0:
- self.app.inform.emit("[WARNING] The Cut Z parameter has positive value. "
+ self.app.inform.emit(_tr("[WARNING] The Cut Z parameter has positive value. "
"It is the depth value to cut into material.\n"
"The Cut Z parameter needs to have a negative value, assuming it is a typo "
"therefore the app will convert the value to negative."
- "Check the resulting CNC code (Gcode etc).")
+ "Check the resulting CNC code (Gcode etc)."))
self.z_cut = -self.z_cut
elif self.z_cut == 0:
- self.app.inform.emit("[WARNING] The Cut Z parameter is zero. "
- "There will be no cut, skipping %s file" % geometry.options['name'])
+ self.app.inform.emit(_tr("[WARNING] The Cut Z parameter is zero. "
+ "There will be no cut, skipping %s file") % geometry.options['name'])
return 'fail'
if self.z_move is None:
- self.app.inform.emit("[ERROR_NOTCL] Travel Z parameter is None or zero.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] Travel Z parameter is None or zero."))
return 'fail'
if self.z_move < 0:
- self.app.inform.emit("[WARNING] The Travel Z parameter has negative value. "
+ self.app.inform.emit(_tr("[WARNING] The Travel Z parameter has negative value. "
"It is the height value to travel between cuts.\n"
"The Z Travel parameter needs to have a positive value, assuming it is a typo "
"therefore the app will convert the value to positive."
- "Check the resulting CNC code (Gcode etc).")
+ "Check the resulting CNC code (Gcode etc)."))
self.z_move = -self.z_move
elif self.z_move == 0:
- self.app.inform.emit("[WARNING] The Z Travel parameter is zero. "
- "This is dangerous, skipping %s file" % self.options['name'])
+ self.app.inform.emit(_tr("[WARNING] The Z Travel parameter is zero. "
+ "This is dangerous, skipping %s file") % self.options['name'])
return 'fail'
## Index first and last points in paths
@@ -5774,7 +5774,7 @@ class CNCjob(Geometry):
if not kwargs:
log.debug("camlib.generate_from_solderpaste_geo() --> No tool in the solderpaste geometry.")
- self.app.inform.emit("[ERROR_NOTCL] There is no tool data in the SolderPaste geometry.")
+ self.app.inform.emit(_tr("[ERROR_NOTCL] There is no tool data in the SolderPaste geometry."))
# this is the tool diameter, it is used as such to accommodate the postprocessor who need the tool diameter