Path OPs don't work with translated UI

Here's the place for discussion related to CAM/CNC and the development of the Path module.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
herbk
Veteran
Posts: 2655
Joined: Mon Nov 03, 2014 3:45 pm
Location: Windsbach, Bavarya (Germany)

Path OPs don't work with translated UI

Post by herbk »

Hi,
since FC 0.20.26498 (Git) AppImage the Path OPs are not working if one uses a not english UI ! (Testet in German and Francais)

Some input fields for selekting OP deteils are translated now, what's the reason for that in my mind. Each try to get an path ends up with this error message:

Code: Select all

File "/tmp/.mount_FreeCAeWl1Rg/usr/Mod/Path/PathScripts/PathOpGui.py", line 1156, in clicked
    self.panelGetFields()
  File "/tmp/.mount_FreeCAeWl1Rg/usr/Mod/Path/PathScripts/PathOpGui.py", line 1171, in panelGetFields
    page.pageGetFields()
  File "/tmp/.mount_FreeCAeWl1Rg/usr/Mod/Path/PathScripts/PathOpGui.py", line 236, in pageGetFields
    self.getFields(self.obj)
  File "/tmp/.mount_FreeCAeWl1Rg/usr/Mod/Path/PathScripts/PathProfileGui.py", line 76, in getFields
    obj.Side = str(self.form.cutSide.currentText())
<class 'ValueError'>: 'Außen' is not part of the enumeration in Ringgeni_2x16_Spulen#Profile.Side
Today i get the new Appimage, same problem here...

OS: openSUSE Tumbleweed (KDE//usr/share/xsessions/plasma5)
Word size of FreeCAD: 64-bit
Version: 0.20.26554 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 817c14b)
Hash: 817c14b16af681b06aec7d8c79f744c7a88fa3c3
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: German/Germany (de_DE)
Gruß Herbert
User avatar
onekk
Veteran
Posts: 6098
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Path OPs don't work with translated UI

Post by onekk »

Maybe this is related to some "hardcoded names".

As example if you translate "Job" many automatism will fail I've encountered this behaviour when dealing with scripting when I rename a "Job" without keeping "Job" as first characters of the Name they will be not taken in account.

maybe poking @sliptonic
sliptonic wrote: Mon Dec 06, 2021 6:40 pm :D
Will make some light if my guess is right.


Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
sliptonic
Veteran
Posts: 3453
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Path OPs don't work with translated UI

Post by sliptonic »

Based on the error, my first guess would be something in PathOpGui. Those files were last modified in August.

If we can find a git commit or app image where it was known to work correctly, it should be easy to track down when it changed.
herbk
Veteran
Posts: 2655
Joined: Mon Nov 03, 2014 3:45 pm
Location: Windsbach, Bavarya (Germany)

Re: Path OPs don't work with translated UI

Post by herbk »

Hi Sliptonic,
sliptonic wrote: Tue Dec 07, 2021 5:24 pm Based on the error, my first guess would be something in PathOpGui. Those files were last modified in August.

If we can find a git commit or app image where it was known to work correctly, it should be easy to track down when it changed.
That's no problem: 0.20.26375 (Git) AppImage works, but there the UI is not translated. It's just 2 versions back, so i don't think it's based at the modifications from August, - exept the mods are releated to UI translations...

In my mind there is a overenthusiastic translater at work....
Gruß Herbert
User avatar
sliptonic
Veteran
Posts: 3453
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Path OPs don't work with translated UI

Post by sliptonic »

I think you're right. It seems like it might be related to translation of some of the enum strings. I'm narrowing it down
User avatar
sliptonic
Veteran
Posts: 3453
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Path OPs don't work with translated UI

Post by sliptonic »

The problem was introduced by this commit
https://github.com/FreeCAD/FreeCAD/comm ... 722a0b8f0f

I'm not sure how to fix this.
chrisb
Veteran
Posts: 53786
Joined: Tue Mar 17, 2015 9:14 am

Re: Path OPs don't work with translated UI

Post by chrisb »

Do these translations come from crowdin? Can we do some voting to exclude them, or has this to be done on the FreeCAD side?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
User avatar
sliptonic
Veteran
Posts: 3453
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Path OPs don't work with translated UI

Post by sliptonic »

I don't know. I don't really understand the translation/crowdin thing as well as I probably should.
Russ4262
Posts: 941
Joined: Sat Jun 30, 2018 3:22 pm
Location: Oklahoma
Contact:

Re: Path OPs don't work with translated UI

Post by Russ4262 »

One way to solve this is with a change in coding related to how the GUI sets enumerations. Currently, most enumerations are hard coded in UI files. However, this is the source of the problem because when the backend wants to lookup an enumeration in a list/dictionary, it cannot find it because the text has been translated to another language other than coding language (English).

One solution is to store the enumerations in the backend, and then load them dynamically after the UI file is loaded. The PathOpGui.selectInComboBox() helper would need to be rewritten to retrieve the same UI index value from the base op enumeration list, rather than looking up an index in the enumeration list via a text search in the enumerations list. Other existing helpers might need modification also. Additional helpers might need to be written to load the enumeration lists dynamically. These helper mods should not be overly difficult, as they do not seem overly complex in task and purpose.

This solution has a number of benefits:
* Devs do not have to maintain enumeration lists in multiple files, UI and backend.
* Translations should not affect available enumerations.
* Future changes do not have to worry about enumeration lists being in sync between UI and backend.
* Modifying enumerations lists would only take place in the backend, as the UI would simply mirror the backend dynamically.

Possible problem:
* I am not certain as to how to get enumerations in the backend to be passed to the translation methods. I have an idea of how to do it, but I have not tested it.

This solution is partially implemented already with PathProfile, PathSlot, PathSurface, and PathWaterline. I say partially because the enumeration lists are already easily available in these backends.

This solution is already active in the Slot operation as some of the enumeration lists are updated dynamically depending upon selections in the GUI.

........
An alternate solution might be to flag the enumerations as non-translatable within the UI files. I do not recommend this solution, as multi-language support is very important.


Just my thoughts. Nothing more.

Russell
User avatar
sliptonic
Veteran
Posts: 3453
Joined: Tue Oct 25, 2011 10:46 pm
Location: Columbia, Missouri
Contact:

Re: Path OPs don't work with translated UI

Post by sliptonic »

That sounds correct but why was this never a problem before?
Post Reply