shaise / FreeCAD_FastenersWB

A workbench to add/attach various fasteners to parts
GNU General Public License v2.0
287 stars 86 forks source link

Fix error on `FSGetToolbarItem()` #384

Closed hasecilu closed 6 months ago

hasecilu commented 6 months ago
  1. With the updated translations an error occurs due to the toolbar names be translated, "FS Commands" is passed to FSGetToolbarItem() but should be the translated string.
    12:49:03  'NoneType' object has no attribute 'setCheckable'
    12:49:03  Traceback (most recent call last):
    File "/home/uli/.local/share/FreeCAD/Mod/FastenersWB/./InitGui.py", line 107, in Activated
    FastenerBase.InitCheckables()
    File "/home/uli/.local/share/FreeCAD/Mod/FastenersWB/./FastenerBase.py", line 863, in InitCheckables
    matchOuterButton.setCheckable(True)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  2. A while ago a tried to migrate translation script but I got errors from pylupdate6 saying that there was an error on first line of some file, so I left pylupdate5. Today I investigate about it and it seems there was an extra special byte there that make it fail.

    pylupdate6: Invalid syntax at line 1 of CountersunkHoles.py:
    # -*- coding: utf-8 -*-
    • I deleted all content of "bad" files and still got error, then with hexdump view the content of the files which was not empty, normally the output is null with empty files.
      $ hexdump CountersunkHoles.py
      0000000 bbef 00bf
      0000003
    • ChatGPT: The hex dump output bbef 00bf indicates the presence of a Byte Order Mark (BOM) at the start of your file. Specifically, EF BB BF is the UTF-8 BOM... A Byte Order Mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream...
    • Replacing those bytes with sed did the trick and now we're able to make pylupdate6 to parse the files.
  3. After change 2, update script and translation files to have the new translated string that solves error from 1
kaktusus commented 6 months ago

A simpler solution was to copy the contents of the file into a properly created empty file ... :wink:

shaise commented 6 months ago

@kaktusus ,

Does this fix affect crowdin? Is it safe to merge?

shai

kaktusus commented 6 months ago

This is unrelated, if there are new strings to translate I will generate them today and import them into Crowdin. For two weeks again, we can do import translations.

In addition, colleague hasecilu is a responsible person, knows what he does. We also cooperate together.

shaise commented 6 months ago

@kaktusus , Sounds great! @hasecilu Thanks!

hasecilu commented 6 months ago

This is unrelated, if there are new strings to translate I will generate them today and import them into Crowdin.

Actually the new string should be translated exactly the same way as the toolbar in order to not provoke errors, on Crowdin same strings are tied so should not be problems.