Skip to content

Commit

Permalink
Make WB name, WB tooltip and menus translatables
Browse files Browse the repository at this point in the history
FreeCADGui.addLanguagePath(Asm4_trans)
&
FreeCADGui.updateLocale()
need to be moved over the workbench class to be able to translate
the WB name and tooltip
  • Loading branch information
hasecilu committed Mar 2, 2024
1 parent 808c8e5 commit ed5284b
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 24 deletions.
20 changes: 12 additions & 8 deletions InitGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
# I don't like this being here
import selectionFilter

from TranslateUtils import translate

global Asm4_icon, Asm4_path, Asm4_trans
Asm4_path = os.path.dirname(Asm4_locator.__file__)
Asm4_icon = os.path.join(Asm4_path, "Resources/icons/Assembly4.svg")
Asm4_trans = os.path.join(Asm4_path, "Resources/translations")

FreeCADGui.addLanguagePath(Asm4_trans)
FreeCADGui.updateLocale()


"""
+-----------------------------------------------+
Expand All @@ -43,10 +48,12 @@


class Assembly4Workbench(Workbench):
from TranslateUtils import translate

global Asm4_icon
global selectionFilter
MenuText = "Assembly 4"
ToolTip = "Assembly 4 workbench"
MenuText = translate("Asm4", "Assembly 4")
ToolTip = translate("Asm4", "Assembly 4 workbench")
Icon = Asm4_icon

def __init__(self):
Expand Down Expand Up @@ -89,9 +96,6 @@ def GetClassName(self):
def Initialize(self):
from TranslateUtils import translate

FreeCADGui.addLanguagePath(Asm4_trans)
FreeCADGui.updateLocale()

# Assembly4 version info
# with file package.xml (FreeCAD ≥0.21)
packageFile = os.path.join(Asm4_path, "package.xml")
Expand Down Expand Up @@ -212,17 +216,17 @@ def Initialize(self):

# Define Menus
# commands to appear in the Assembly4 menu 'Assembly'
self.appendMenu(translate("Workbench", "&Assembly"), self.assemblyMenuItems())
self.appendMenu(translate("Asm4", "&Assembly"), self.assemblyMenuItems())
self.dot()

# put all constraints related commands in a separate menu
self.appendMenu("&Constraints", self.constraintsMenuItems())
self.appendMenu(translate("Asm4", "&Constraints"), self.constraintsMenuItems())
self.dot()

# self.appendMenu("&Geometry",["Asm4_newPart"])

# additional entry in the Help menu
# self.appendMenu(translate("Workbench", "&Help"), ["Asm4_Help"])
# self.appendMenu(translate("Asm4", "&Help"), ["Asm4_Help"])
self.appendMenu("&Help", ["Asm4_Help"])
self.dot()

Expand Down
28 changes: 20 additions & 8 deletions Resources/translations/asm4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,31 @@
<TS version="2.1">
<context>
<name>Asm4</name>
<message>
<location filename="../../InitGui.py" line="49"/>
<source>Assembly 4</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../InitGui.py" line="50"/>
<source>Assembly 4 workbench</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../InitGui.py" line="126"/>
<source>Initializing Assembly4 workbench</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../InitGui.py" line="216"/>
<source>&amp;Assembly</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../InitGui.py" line="220"/>
<source>&amp;Constraints</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../InitGui.py" line="393"/>
<location filename="../../InitGui.py" line="231"/>
Expand Down Expand Up @@ -407,12 +427,4 @@ If an assembly is selected, the new fastener will be inside that assembly.&lt;/p
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Workbench</name>
<message>
<location filename="../../InitGui.py" line="215"/>
<source>&amp;Assembly</source>
<translation type="unfinished"></translation>
</message>
</context>
</TS>
22 changes: 14 additions & 8 deletions treeSelectionOverride.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from FreeCAD import Console as FCC

import Asm4_libs as Asm4

from TranslateUtils import translate


observer = None
Expand All @@ -22,17 +22,23 @@
| main class |
+-----------------------------------------------+
"""
class treeSelectionOverrideCmd( QtGui.QDialog):


class treeSelectionOverrideCmd(QtGui.QDialog):
def __init__(self):
super(treeSelectionOverrideCmd,self).__init__()
super(treeSelectionOverrideCmd, self).__init__()

def GetResources(self):
return {"MenuText": "Enable/Disable 3D View selection mode",
"ToolTip": "Enable/Disable 3D View selection mode\n\n" + \
"Allows to select a Link object in the 3D view\n" + \
return {
"MenuText": "Enable/Disable 3D View selection mode",
"ToolTip": translate(
"Commands6",
"Enable/Disable 3D View selection mode\n\n"
"Allows to select a Link object in the 3D view\n"
"window instead of the Model tree",
"Pixmap" : os.path.join( Asm4.iconPath , 'Asm4_enableLinkSelection.svg')
}
),
"Pixmap": os.path.join(Asm4.iconPath, "Asm4_enableLinkSelection.svg"),
}

def IsActive(self):
return True
Expand Down

0 comments on commit ed5284b

Please sign in to comment.