Translation in FEM

About the development of the FEM module/workbench.

Moderator: bernd

User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Translation in FEM

Post by Evgeniy »

chennes wrote: Thu Sep 30, 2021 6:39 pm Maybe, I don't know how it happened in the first place. My understanding is that it's incorrect for their to be any actual translations in the Module.ts files, that all actual translations should be in Module_lang.ts files.
Now I understand what was the mistake. ts file contains:

Code: Select all

        <source>Windows</source>
        <translation>Windows</translation>
instead:

Code: Select all

        <source>Windows</source>
        <translation type="unfinished"></translation>
This is very strange.
Last edited by Evgeniy on Fri Oct 01, 2021 1:54 pm, edited 1 time in total.
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

I'm going to add it to the PR and have Yorik look at it. There really should not be translations in those top-level TS files (and of course if the language isn't specified they won't get used anyway).
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
david69
Veteran
Posts: 1773
Joined: Wed Jan 01, 2014 7:48 pm

Re: Translation in FEM

Post by david69 »

chennes, sorry if I didn't get clearly the meaning of this thread, but can it explain why we still don't see the right translations on the GUI.
when I check crowdin, for example the translation of Solver Calculix has been done 4 yrs ago and we still don't see it.


OS: Ubuntu 18.04.6 LTS (LXDE/Lubuntu)
Word size of FreeCAD: 64-bit
Version: 0.20.
Build type: Release
Branch: unknown
Hash: 09e2e7acfa291ae262f59bc15f79a452dba21851
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.5.2
Locale: French/France (fr_FR)
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

It doesn't seem to be directly related, though maybe Yorik knows better. For example, if I look at the string "Solver CalculiX Standard" (the menu text), I see that it is in the FEM.ts file, and I can see the French translation correctly appearing in the FEM_fr.ts file. The line number doesn't match, though, so maybe it is in fact still out of date? Yorik when did you last sync the CrowdIn with the main repository?
yorik wrote: ping
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Translation in FEM

Post by wmayer »

The ts. files seem very outdated because they reference to files that do not even exist any more. However, this is not the reason why the strings are not translated. The problem is that many context strings do not match any more with the command names.

By rerunning the lupdate tool the issue won't be fixed because for some reason the QT_TR_NOOB/QT_TRANSLATE_NOOB function has been removed in all command classes and thus the Qt utility won't be able to collect any of these strings and add them to the .ts files.
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Translation in FEM

Post by bernd »

wmayer wrote: Sat Oct 30, 2021 11:03 pm The ts. files seem very outdated because they reference to files that do not even exist any more. However, this is not the reason why the strings are not translated. The problem is that many context strings do not match any more with the command names.

By rerunning the lupdate tool the issue won't be fixed because for some reason the QT_TR_NOOB/QT_TRANSLATE_NOOB function has been removed in all command classes and thus the Qt utility won't be able to collect any of these strings and add them to the .ts files.
If it is about the Python command classes it probably could have been me. :oops: But in the regard of Python commands it even could have been the case they never ever existet and just noone complained about. :shock:

Would you give an example how it needs to be coded? I would fix them.
wmayer
Founder
Posts: 20241
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: Translation in FEM

Post by wmayer »

But in the regard of Python commands it even could have been the case they never ever existet and just noone complained about.
This is rather unlikely because the .ts files include several command-related string literals (e.g. for FEM_ResultShow). When I run pyside2-lupdate
for commands.py the ts file will be empty.
Would you give an example how it needs to be coded? I would fix them.
The translation of Python command-related string literals works this way:
  • mark the text with QT_TRANSLATE_NOOP where as first argument you specify the context string. The context string is the one you use to register the command
  • run the script to update the .ts file (done by Yorik)
  • translate the strings and update the .qm files (Yorik and community)
Example code:
Change

Code: Select all

class _ResultShow(CommandManager):
    "The FEM_ResultShow command definition"

    def __init__(self):
        super(_ResultShow, self).__init__()
        self.menutext = "Show result"
        self.accel = "R, S"
        self.tooltip = "Shows and visualizes selected result data"
        self.is_active = "with_selresult"

    def Activated(self):
        self.selobj.ViewObject.Document.setEdit(self.selobj.ViewObject, 0)
to

Code: Select all

class _ResultShow(CommandManager):
    "The FEM_ResultShow command definition"

    def __init__(self):
        super(_ResultShow, self).__init__()
        self.menutext = Qt.QT_TRANSLATE_NOOP("FEM_ResultShow", "Show result")
        self.accel = "R, S"
        self.tooltip = Qt.QT_TRANSLATE_NOOP("FEM_ResultShow", "Shows and visualizes selected result data")
        self.is_active = "with_selresult"

    def Activated(self):
        self.selobj.ViewObject.Document.setEdit(self.selobj.ViewObject, 0)
You get

Code: Select all

Qt.QT_TRANSLATE_NOOP
with

Code: Select all

from FreeCAD import Qt
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Translation in FEM

Post by bernd »

wmayer wrote: Mon Nov 01, 2021 12:29 pm
But in the regard of Python commands it even could have been the case they never ever existet and just noone complained about.
This is rather unlikely because the .ts files include several command-related string literals (e.g. for FEM_ResultShow). When I run pyside2-lupdate
for commands.py the ts file will be empty.
https://github.com/FreeCAD/FreeCAD/comm ... aL901-R621 :oops: :roll:
User avatar
bernd
Veteran
Posts: 12849
Joined: Sun Sep 08, 2013 8:07 pm
Location: Zürich, Switzerland
Contact:

Re: Translation in FEM

Post by bernd »

User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Translation in FEM

Post by Evgeniy »

Of course, a lot of time has passed. Lines for translation appeared. The interface looks much better now.
Post Reply