Translating external workbenches

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
EdgarRobles
Posts: 70
Joined: Fri Jul 31, 2015 1:35 pm
Location: Mexico
Contact:

Re: Translating external workbenches

Postby EdgarRobles » Sun Dec 22, 2019 10:39 pm

Hi FreeCAD team,

I trying to translate Dodo workbench https://github.com/oddtopus/dodo i have made whole procedure described on this page https://www.freecadweb.org/wiki/Transla ... _workbench without success.
This is what i have done:
-Edit some test code in order to generate one .ts file. I successfully made it through pyside2-lupdate command on windows 10.
-Made a translations folder behind InitGui.py dodo workbench file and es_ES.ts and es_ES.qm files inside.
-addtranslationpath function point to translation folder at the right way and its placed at the begining in InitGui.py .
Freecad load dodo workbench with this changes without errors.
I'm not sure what a missing.

OS: windows 10
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.16117
Build type: Release
Branch: releases/FreeCAD-18
Hash: dbb4cc6415bac848a294f03b80f65e888d531742
Python version: 3.6.6
Qt version: 5.6.2
Coin version: 4.0.0a
OCC version 7.3.0
Locale: english/UnitedStates (en_US)


InitGui.py file

Code: Select all

class dodo ( Workbench ):
  import DraftSnap
  import sys, FreeCAD,os,dummyos
  from PySide.QtCore import QT_TRANSLATE_NOOP
  FreeCADGui.addLanguagePath(os.path.join(dummyos.relpath,"Resources"+os.sep+"translations"))
  FreeCAD.Console.PrintMessage(os.path.join(dummyos.relpath,"Resources"+os.sep+"translations"))
ES_es.ts

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="es">
<context>
    <name>FrameBranchManager</name>
    <message>
        <location filename="CFrame.py" line="374"/>
        <source>FrameBranch Manager</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="377"/>
        <source>Open FrameBranch Manager</source>
        <translation>Abre gestor de marcos</translation>
    </message>
</context>
<context>
    <name>adjustFrameAngle</name>
    <message>
        <location filename="CFrame.py" line="281"/>
        <source>adjustFrameAngle</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="284"/>
        <source>Adjust the angle of frame by two edges</source>
        <translation>Adjuste del angulo del marco por medio de dos aristas</translation>
    </message>
</context>
<context>
    <name>alignEdge</name>
    <message>
        <location filename="CFrame.py" line="209"/>
        <source>Mate the edges</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="212"/>
        <source>Join two edges: select two or pre-select several</source>
        <translation>Une dos aristas:selecciona dos o pre selecciona varias</translation>
    </message>
</context>
<context>
    <name>alignFlange</name>
    <message>
        <location filename="CFrame.py" line="115"/>
        <source>alignFlange</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="118"/>
        <source>Rotates the section of the beam to make the faces parallel to another face</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>dodo</name>
    <message>
        <location filename="InitGui.py" line="155"/>
        <source>Frame tools</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="InitGui.py" line="156"/>
        <source>Pype tools</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="InitGui.py" line="157"/>
        <source>Utils</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="InitGui.py" line="158"/>
        <source>QkMenus</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>extend</name>
    <message>
        <location filename="CFrame.py" line="266"/>
        <source>extendTheBeam</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="269"/>
        <source>Extend the beam either to a face, a vertex or the c.o.m. of the selected object</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>frameIt</name>
    <message>
        <location filename="CFrame.py" line="44"/>
        <source>Place one-beam over one-edge</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="47"/>
        <source>Place one beam after the other over the edges</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>insertPath</name>
    <message>
        <location filename="CFrame.py" line="318"/>
        <source>insert Path</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="363"/>
        <source>Creates one path along selected edges</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>insertSection</name>
    <message>
        <location filename="CFrame.py" line="388"/>
        <source>Insert sections</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="394"/>
        <source>Creates customized beam profiles 2D</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>levelBeam</name>
    <message>
        <location filename="CFrame.py" line="176"/>
        <source>Flush the surfaces</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="179"/>
        <source>Shift the beams to line-up the faces to the first selection (faces must be //)</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>pivotBeam</name>
    <message>
        <location filename="CFrame.py" line="227"/>
        <source>pivotTheBeam</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="230"/>
        <source>Rotates the beam around an axis (edge or center-of-curvature)</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>reverseBeam</name>
    <message>
        <location filename="CFrame.py" line="83"/>
        <source>Reverse orientation</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="100"/>
        <source>Reverse the orientation of selected objects</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>rotJoin</name>
    <message>
        <location filename="CFrame.py" line="300"/>
        <source>rotJoinEdge</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="303"/>
        <source>Rotates and align the beam according another edge</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>shiftBeam</name>
    <message>
        <location filename="CFrame.py" line="143"/>
        <source>shiftTheBeam</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="146"/>
        <source>Translate objects by vectors defined on existing geometry</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>spinSect</name>
    <message>
        <location filename="CFrame.py" line="63"/>
        <source>Spin beams by 45 deg.</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="66"/>
        <source>Rotates the section of the beam by 45 degrees</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>stretchBeam</name>
    <message>
        <location filename="CFrame.py" line="249"/>
        <source>stretchTheBeam</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="CFrame.py" line="252"/>
        <source>Changes the length of the beam, either according a preselected edge or a direct input</source>
        <translation type="unfinished"></translation>
    </message>
</context>
</TS>
main.pro

Code: Select all

SOURCES = CFrame.py InitGui.py fCmd.py CPipe.py CUtils.py dodoDialogs.py dodoPM.py fForms.py fObservers.py
TRANSLATIONS =  ES_es.ts
User avatar
Kunda1
Posts: 8479
Joined: Thu Jan 05, 2017 9:03 pm

Re: Translating external workbenches

Postby Kunda1 » Fri Jan 17, 2020 11:27 am

Alternative Translation method for FreeCAD Addons? https://forum.freecadweb.org/viewtopic.php?f=10&t=42516
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
alex.zhang
Posts: 12
Joined: Wed Jan 08, 2020 6:47 am

Re: Translating external workbenches

Postby alex.zhang » Wed Feb 19, 2020 2:54 pm

@yorik
I am trying to translate BIM workbench to Chinese and almost done.
There are several problems.

1. Move to trash menu still display English.
BimCommands.py

Code: Select all

class BIM_Trash:


    def GetResources(self):

        return {'Pixmap'  : os.path.join(os.path.dirname(__file__),"icons","BIM_Trash.svg"),
                'MenuText': QT_TRANSLATE_NOOP("BIM_TogglePanels", "Move to Trash"),
                'ToolTip' : QT_TRANSLATE_NOOP("BIM_TogglePanels", "Moves the selected objects to the Trash folder"),
                'Accel': 'Shift+Del'}
2. Welcome screen dialog(dialogWelcome.ui), views dialog(dialogViews.ui) and status icon still display English.
InitGui.py

Code: Select all

        if FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/BIM").GetBool("FirstTime",True) and (not hasattr(FreeCAD,"TestEnvironment")):
            todo.delay(FreeCADGui.runCommand,"BIM_Welcome")
        todo.delay(BimCommands.setStatusIcons,True)
3. I cannot find where "BIM Views manager" is, which is shown in toolbar context menu, please see attached 1.png.

4. Even I set language to Chinese, BIM workbench require changing to another language and back to Chinese for the translation to work. Is there a work around?

BTW, I confirm that all strings are translated and included in ts and qm file.

Thanks.
Attachments
1.png
1.png (10.05 KiB) Viewed 522 times
User avatar
kkremitzki
Posts: 2161
Joined: Thu Mar 03, 2016 9:52 pm
Location: Texas

Re: Translating external workbenches

Postby kkremitzki » Wed Feb 19, 2020 7:03 pm

谢谢! (Thank you! for helping with translation.)
Like my FreeCAD work? I'd appreciate any level of support via Patreon, Liberapay, or PayPal! Read more about what I do at my blog.
User avatar
Kunda1
Posts: 8479
Joined: Thu Jan 05, 2017 9:03 pm

Re: Translating external workbenches

Postby Kunda1 » Sun Feb 23, 2020 11:18 pm

Can we please figure out why translations aren't working for external workbenches? :(
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
User avatar
alex.zhang
Posts: 12
Joined: Wed Jan 08, 2020 6:47 am

Re: Translating external workbenches

Postby alex.zhang » Mon Feb 24, 2020 2:33 pm

Kunda1 wrote:
Sun Feb 23, 2020 11:18 pm
Can we please figure out why translations aren't working for external workbenches? :(
Is there any approach? I checked the ts file and sure the translated words are there. The ts file is released to qm file.

Thanks.
User avatar
Kunda1
Posts: 8479
Joined: Thu Jan 05, 2017 9:03 pm

Re: Translating external workbenches

Postby Kunda1 » Mon Feb 24, 2020 2:40 pm

Should be explained in Translating_an_external_workbench
But I don't know the details of where the problem is
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
marmni
Posts: 44
Joined: Sat Nov 30, 2013 3:53 pm

Re: Translating external workbenches

Postby marmni » Mon Feb 24, 2020 4:31 pm

Hi,

"Can we please figure out why translations aren't working for external workbenches?"
I was able to load translation for PCB WB. Put FreeCADGui.addLanguagePath("") just after Initialize() def.

Code: Select all

def Initialize(self):
        FreeCADGui.addLanguagePath(":/data/translations")
        ....

However in "InitGui.py" code

Code: Select all

FreeCAD.Console.PrintMessage(translate("PCB", "InitGui") + "\n")
print(translate("PCB", "InitGui"))
def Initialize () returns "InitGui", but def Activated () returns correct translation.
Attachments
pcb_tr_pl.png
pcb_tr_pl.png (22.29 KiB) Viewed 398 times
User avatar
alex.zhang
Posts: 12
Joined: Wed Jan 08, 2020 6:47 am

Re: Translating external workbenches

Postby alex.zhang » Wed Mar 11, 2020 6:59 am

I fixed the BIM Workbench tranlsation issue by add one line code after digging into the source code.

Code: Select all

        
Log ('Loading BIM module... done\n')
FreeCADGui.updateLocale() # refresh the language according to current locale.
Hope it is helpful.

Alex.
User avatar
Kunda1
Posts: 8479
Joined: Thu Jan 05, 2017 9:03 pm

Re: Translating external workbenches

Postby Kunda1 » Wed Mar 11, 2020 1:30 pm

alex.zhang wrote:
Wed Mar 11, 2020 6:59 am
I fixed the BIM Workbench tranlsation issue by add one line code after digging into the source code.

Code: Select all

        
Log ('Loading BIM module... done\n')
FreeCADGui.updateLocale() # refresh the language according to current locale.
Nice! Are you on Github? Can you link to your fork? Actually link to the line number you edited?
Want to contribute back to FC? Checkout:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features