Skip to content

Commit

Permalink
Fixed translation system in Arch & Draft
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Jan 7, 2014
1 parent c19e42c commit 19865c2
Show file tree
Hide file tree
Showing 24 changed files with 173 additions and 173 deletions.
14 changes: 7 additions & 7 deletions src/Mod/Arch/ArchAxis.py
Expand Up @@ -31,7 +31,7 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

def makeAxis(num=5,size=1,name=str(translate("Arch","Axes"))):
def makeAxis(num=5,size=1,name=translate("Arch","Axes")):
'''makeAxis(num,size): makes an Axis System
based on the given number of axes and interval distances'''
obj = FreeCAD.ActiveDocument.addObject("App::FeaturePython",name)
Expand All @@ -57,7 +57,7 @@ def GetResources(self):
'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Axis","Creates an axis system.")}

def Activated(self):
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Axis")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Axis"))
FreeCADGui.doCommand("import Arch")
sel = FreeCADGui.Selection.getSelection()
st = Draft.getObjectsOfType(sel,"Structure")
Expand All @@ -71,9 +71,9 @@ def Activated(self):
class _Axis:
"The Axis object"
def __init__(self,obj):
obj.addProperty("App::PropertyFloatList","Distances","Arch", str(translate("Arch","The intervals between axes")))
obj.addProperty("App::PropertyFloatList","Angles","Arch", str(translate("Arch","The angles of each axis")))
obj.addProperty("App::PropertyFloat","Length","Arch", str(translate("Arch","The length of the axes")))
obj.addProperty("App::PropertyFloatList","Distances","Arch", translate("Arch","The intervals between axes"))
obj.addProperty("App::PropertyFloatList","Angles","Arch", translate("Arch","The angles of each axis"))
obj.addProperty("App::PropertyFloat","Length","Arch", translate("Arch","The length of the axes"))
obj.addProperty("App::PropertyPlacement","Placement","Base","")
obj.addProperty("Part::PropertyPartShape","Shape","Base","")
self.Type = "Axis"
Expand Down Expand Up @@ -112,8 +112,8 @@ class _ViewProviderAxis:
"A View Provider for the Axis object"

def __init__(self,vobj):
vobj.addProperty("App::PropertyLength","BubbleSize","Arch", str(translate("Arch","The size of the axis bubbles")))
vobj.addProperty("App::PropertyEnumeration","NumberingStyle","Arch", str(translate("Arch","The numbering style")))
vobj.addProperty("App::PropertyLength","BubbleSize","Arch", translate("Arch","The size of the axis bubbles"))
vobj.addProperty("App::PropertyEnumeration","NumberingStyle","Arch", translate("Arch","The numbering style"))
vobj.addProperty("App::PropertyEnumeration","DrawStyle","Base","")
vobj.addProperty("App::PropertyFloat","LineWidth","Base","")
vobj.addProperty("App::PropertyColor","LineColor","Base","")
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Arch/ArchBuilding.py
Expand Up @@ -29,7 +29,7 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

def makeBuilding(objectslist=None,join=False,name=str(translate("Arch","Building"))):
def makeBuilding(objectslist=None,join=False,name=translate("Arch","Building")):
'''makeBuilding(objectslist,[joinmode]): creates a building including the
objects from the given list. If joinmode is True, components will be joined.'''
obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython",name)
Expand All @@ -52,22 +52,22 @@ def Activated(self):
ok = False
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Site","Floor"]:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Type conversion")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("obj = Arch.makeBuilding()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
FreeCADGui.doCommand('FreeCAD.ActiveDocument.removeObject("'+sel[0].Name+'")')
FreeCAD.ActiveDocument.commitTransaction()
ok = True
if not ok:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch"," Create Building")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch"," Create Building"))
ss = "["
for o in sel:
if len(ss) > 1:
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Floor")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeBuilding("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
Expand Down
28 changes: 14 additions & 14 deletions src/Mod/Arch/ArchCommands.py
Expand Up @@ -137,16 +137,16 @@ def removeComponents(objectsList,host=None):
if o.Base.Support:
if isinstance(o.Base.Support,tuple):
if o.Base.Support[0].Name == host.Name:
FreeCAD.Console.PrintMessage(str(translate("Arch","removing sketch support to avoid cross-referencing")))
FreeCAD.Console.PrintMessage(translate("Arch","removing sketch support to avoid cross-referencing"))
o.Base.Support = None
elif o.Base.Support.Name == host.Name:
FreeCAD.Console.PrintMessage(str(translate("Arch","removing sketch support to avoid cross-referencing")))
FreeCAD.Console.PrintMessage(translate("Arch","removing sketch support to avoid cross-referencing"))
o.Base.Support = None
elif o.Base.ExternalGeometry:
for i in range(len(o.Base.ExternalGeometry)):
if o.Base.ExternalGeometry[i][0].Name == host.Name:
o.Base.delExternal(i)
FreeCAD.Console.PrintMessage(str(translate("Arch","removing sketch support to avoid cross-referencing")))
FreeCAD.Console.PrintMessage(translate("Arch","removing sketch support to avoid cross-referencing"))
break
host.Subtractions = s
else:
Expand Down Expand Up @@ -189,16 +189,16 @@ def fixWindow(obj):
if obj.Base.Support:
if isinstance(o.Base.Support,tuple):
if obj.Base.Support[0]:
FreeCAD.Console.PrintMessage(str(translate("Arch","removing sketch support to avoid cross-referencing")))
FreeCAD.Console.PrintMessage(translate("Arch","removing sketch support to avoid cross-referencing"))
obj.Base.Support = None
elif obj.Base.Support:
FreeCAD.Console.PrintMessage(str(translate("Arch","removing sketch support to avoid cross-referencing")))
FreeCAD.Console.PrintMessage(translate("Arch","removing sketch support to avoid cross-referencing"))
obj.Base.Support = None
if hasattr(obj.Base,"ExternalGeometry"):
if obj.Base.ExternalGeometry:
for i in range(len(obj.Base.ExternalGeometry)):
obj.Base.delExternal(0)
FreeCAD.Console.PrintMessage(str(translate("Arch","removing sketch external references to avoid cross-referencing")))
FreeCAD.Console.PrintMessage(translate("Arch","removing sketch external references to avoid cross-referencing"))

def copyProperties(obj1,obj2):
'''copyProperties(obj1,obj2): Copies properties values from obj1 to obj2,
Expand Down Expand Up @@ -337,14 +337,14 @@ def getCutVolume(cutplane,shapes):
else:
p = cutplane.copy().Faces[0]
except:
FreeCAD.Console.PrintMessage(str(translate("Arch","Invalid cutplane")))
FreeCAD.Console.PrintMessage(translate("Arch","Invalid cutplane"))
return None,None,None
ce = p.CenterOfMass
ax = p.normalAt(0,0)
u = p.Vertexes[1].Point.sub(p.Vertexes[0].Point).normalize()
v = u.cross(ax)
if not bb.isCutPlane(ce,ax):
FreeCAD.Console.PrintMessage(str(translate("Arch","No objects are cut by the plane")))
FreeCAD.Console.PrintMessage(translate("Arch","No objects are cut by the plane"))
return None,None,None
else:
corners = [FreeCAD.Vector(bb.XMin,bb.YMin,bb.ZMin),
Expand Down Expand Up @@ -567,19 +567,19 @@ def check(objectslist,includehidden=False):
else:
s = o.Shape
if (not s.isClosed()) and (not (Draft.getType(o) == "Axis")):
bad.append([o,str(translate("Arch","is not closed"))])
bad.append([o,translate("Arch","is not closed")])
elif not s.isValid():
bad.append([o,str(translate("Arch","is not valid"))])
bad.append([o,translate("Arch","is not valid")])
elif (not s.Solids) and (not (Draft.getType(o) == "Axis")):
bad.append([o,str(translate("Arch","doesn't contain any solid"))])
bad.append([o,translate("Arch","doesn't contain any solid")])
else:
f = 0
for sol in s.Solids:
f += len(sol.Faces)
if not sol.isClosed():
bad.append([o,str(translate("Arch","contains a non-closed solid"))])
bad.append([o,translate("Arch","contains a non-closed solid")])
if len(s.Faces) != f:
bad.append([o,str(translate("Arch","contains faces that are not part of any solid"))])
bad.append([o,translate("Arch","contains faces that are not part of any solid")])
return bad


Expand All @@ -593,7 +593,7 @@ def addFixture(fixture,baseobject):
if baseobject.ViewObject.DisplayMode != "Detailed":
fixture.ViewObject.hide()
else:
FreeCAD.Console.PrintMessage(str(translate("Arch","This object has no support for fixtures")))
FreeCAD.Console.PrintMessage(translate("Arch","This object has no support for fixtures"))

def getTuples(data,scale=1,placement=None):
"""getTuples(data,[scale,placement]): returns a tuple or a list of tuples from a vector
Expand Down
2 changes: 1 addition & 1 deletion src/Mod/Arch/ArchComponent.py
Expand Up @@ -490,7 +490,7 @@ def addSelection(self,document, object, element, position):
del FreeCAD.ArchObserver
elif object == self.watched.Name:
if not element:
FreeCAD.Console.PrintMessage(str(translate("Arch","closing Sketch edit")))
FreeCAD.Console.PrintMessage(translate("Arch","closing Sketch edit"))
if self.hide:
if self.origin:
self.origin.ViewObject.Transparency = 0
Expand Down
10 changes: 5 additions & 5 deletions src/Mod/Arch/ArchFloor.py
Expand Up @@ -29,7 +29,7 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

def makeFloor(objectslist=None,join=True,name=str(translate("Arch","Floor"))):
def makeFloor(objectslist=None,join=True,name=translate("Arch","Floor")):
'''makeFloor(objectslist,[joinmode]): creates a floor including the
objects from the given list. If joinmode is False, components will
not be joined.'''
Expand All @@ -53,7 +53,7 @@ def Activated(self):
ok = False
if (len(sel) == 1):
if Draft.getType(sel[0]) in ["Cell","Site","Building"]:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Type conversion")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Type conversion"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("obj = Arch.makeFloor()")
FreeCADGui.doCommand("Arch.copyProperties(FreeCAD.ActiveDocument."+sel[0].Name+",obj)")
Expand All @@ -67,7 +67,7 @@ def Activated(self):
ss += ","
ss += "FreeCAD.ActiveDocument."+o.Name
ss += "]"
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Floor")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Floor"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeFloor("+ss+")")
FreeCAD.ActiveDocument.commitTransaction()
Expand All @@ -77,9 +77,9 @@ class _Floor:
"The Floor object"
def __init__(self,obj):
obj.addProperty("App::PropertyLength","Height","Arch",
str(translate("Arch","The height of this floor")))
translate("Arch","The height of this floor"))
obj.addProperty("App::PropertyPlacement","Placement","Arch",
str(translate("Arch","The placement of this group")))
translate("Arch","The placement of this group"))
self.Type = "Floor"
obj.Proxy = self
self.Object = obj
Expand Down
4 changes: 2 additions & 2 deletions src/Mod/Arch/ArchFrame.py
Expand Up @@ -31,7 +31,7 @@
__url__ = "http://www.freecadweb.org"


def makeFrame(base,profile,name="Frame"):
def makeFrame(base,profile,name=translate("Arch","Frame")):
"""makeFrame(base,profile,[name]): creates a frame object from a base sketch (or any other object
containing wires) and a profile object (an extrudable 2D object containing faces or closed wires)"""
obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
Expand All @@ -53,7 +53,7 @@ def GetResources(self):
def Activated(self):
s = FreeCADGui.Selection.getSelection()
if len(s) == 2:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Frame")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Frame"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeFrame(FreeCAD.ActiveDocument."+s[0].Name+",FreeCAD.ActiveDocument."+s[1].Name+")")
FreeCAD.ActiveDocument.commitTransaction()
Expand Down
8 changes: 4 additions & 4 deletions src/Mod/Arch/ArchRebar.py
Expand Up @@ -31,7 +31,7 @@
__url__ = "http://www.freecadweb.org"


def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name="Rebar"):
def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name=translate("Arch","Rebar")):
"""makeRebar(baseobj,sketch,[diameter,amount,offset,name]): adds a Reinforcement Bar object
to the given structural object, using the given sketch as profile."""
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
Expand Down Expand Up @@ -83,7 +83,7 @@ def Activated(self):
sk = sel[1].Object
if Draft.getType(sk) == "Sketch":
# we have a base object and a sketch: create the rebar now
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Rebar")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeRebar(FreeCAD.ActiveDocument."+obj.Name+",FreeCAD.ActiveDocument."+sk.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
Expand All @@ -104,7 +104,7 @@ def Activated(self):
sup = obj.Support[0]
else:
sup = obj.Support
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Rebar")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Rebar"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeRebar(FreeCAD.ActiveDocument."+sup.Name+",FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
Expand All @@ -114,7 +114,7 @@ def Activated(self):
print "Arch: error: couldn't extract a base object"
return

FreeCAD.Console.PrintMessage(str(translate("Arch","Please select a base face on a structural object\n")))
FreeCAD.Console.PrintMessage(translate("Arch","Please select a base face on a structural object\n"))
FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Rebar")
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
Expand Down
14 changes: 7 additions & 7 deletions src/Mod/Arch/ArchRoof.py
Expand Up @@ -30,7 +30,7 @@
__author__ = "Yorik van Havre"
__url__ = "http://www.freecadweb.org"

def makeRoof(baseobj=None,facenr=1,angle=45,name=str(translate("Arch","Roof"))):
def makeRoof(baseobj=None,facenr=1,angle=45,name=translate("Arch","Roof")):
'''makeRoof(baseobj,[facenr],[angle],[name]) : Makes a roof based on a
face from an existing object. You can provide the number of the face
to build the roof on (default = 1), the angle (default=45) and a name (default
Expand Down Expand Up @@ -61,24 +61,24 @@ def Activated(self):
if sel.HasSubObjects:
if "Face" in sel.SubElementNames[0]:
idx = int(sel.SubElementNames[0][4:])
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Roof")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+","+str(idx)+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
if obj.isDerivedFrom("Part::Feature"):
if obj.Shape.Wires:
FreeCAD.ActiveDocument.openTransaction(str(translate("Arch","Create Roof")))
FreeCAD.ActiveDocument.openTransaction(translate("Arch","Create Roof"))
FreeCADGui.doCommand("import Arch")
FreeCADGui.doCommand("Arch.makeRoof(FreeCAD.ActiveDocument."+obj.Name+")")
FreeCAD.ActiveDocument.commitTransaction()
FreeCAD.ActiveDocument.recompute()
return
else:
FreeCAD.Console.PrintMessage(str(translate("Arch","Unable to create a roof")))
FreeCAD.Console.PrintMessage(translate("Arch","Unable to create a roof"))
else:
FreeCAD.Console.PrintMessage(str(translate("Arch","Please select a base object\n")))
FreeCAD.Console.PrintMessage(translate("Arch","Please select a base object\n"))
FreeCADGui.Control.showDialog(ArchComponent.SelectionTaskPanel())
FreeCAD.ArchObserver = ArchComponent.ArchSelectionObserver(nextCommand="Arch_Roof")
FreeCADGui.Selection.addObserver(FreeCAD.ArchObserver)
Expand All @@ -88,9 +88,9 @@ class _Roof(ArchComponent.Component):
def __init__(self,obj):
ArchComponent.Component.__init__(self,obj)
obj.addProperty("App::PropertyAngle","Angle","Base",
str(translate("Arch","The angle of this roof")))
translate("Arch","The angle of this roof"))
obj.addProperty("App::PropertyInteger","Face","Base",
str(translate("Arch","The face number of the base object used to build this roof")))
translate("Arch","The face number of the base object used to build this roof"))
self.Type = "Roof"

def execute(self,obj):
Expand Down

0 comments on commit 19865c2

Please sign in to comment.