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 »

You can use -source-language and -target-language in cmd line for set languages:

Code: Select all

lupdate DlgActivateWindowImp.cpp -source-language en -target-language ru -ts FreeCAD.ts
Result:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="ru" sourcelanguage="en">
<context>
    <name>DlgActivateWindowImp</name>
    <message>
        <location filename="DlgActivateWindowImp.cpp" line="55"/>
        <source>Windows</source>
...
http://manpages.ubuntu.com/manpages/bio ... ate.1.html
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

Evgeniy wrote: Thu Sep 30, 2021 4:44 pm You can use -source-language and -target-language in cmd line for set languages:
Even with those options I still get the same error.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
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 4:59 pm
Evgeniy wrote: Thu Sep 30, 2021 4:44 pm You can use -source-language and -target-language in cmd line for set languages:
Even with those options I still get the same error.
Can you show sequence of bash commands?
Which file is causing the error?

We can use for fix function something like this:

Code: Select all

import codecs

def fixTS(file_path):
   file = open(file_path, "r", encoding="utf8"); text=file.read(); file.close()
   text = text.replace('<TS version="2.1">','<TS version="2.1" language="en">')
   file = codecs.open(file_path, "w", "utf-8"); file.write(text); file.close()
 
But maybe there is a better way?
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

The sequence of commands is:

Code: Select all

$ cd src/Mod/Fem
$ qmake -project -o Fem.pro
$ lupdate -no-obsolete Fem.pro -ts Gui/Resources/translations/Fem.ts
The output is:

Code: Select all

File src/Mod/Fem/Gui/Resources/translations/Fem.ts won't be updated: it contains translation but the target language is not recognized
If I try to manually set the target language on the command line I get additional errors about the target language in the file not matching the specified target language.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

OK, I figured out the difference: FEM's Fem.ts file actually has some strings translated, rather than having them all marked as "unfinished", so it has to have its language set. Draft doesn't need it because in the base Draft.ts file 100% of the strings are marked unfinished.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
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 5:14 pm The sequence of commands is:

Code: Select all

$ cd src/Mod/Fem
$ qmake -project -o Fem.pro
$ lupdate -no-obsolete Fem.pro -ts Gui/Resources/translations/Fem.ts
The output is:

Code: Select all

File src/Mod/Fem/Gui/Resources/translations/Fem.ts won't be updated: it contains translation but the target language is not recognized
If I try to manually set the target language on the command line I get additional errors about the target language in the file not matching the specified target language.
Thanks. Is it possible to find Fem.pro on github for watch?
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Translation in FEM

Post by Evgeniy »

For example if we run:
lupdate DlgActivateWindowImp.cpp -ts FreeCAD1.ts
we get:

Code: Select all

<TS version="2.1">
if we run:
lupdate DlgActivateWindowImp.cpp -ts FreeCAD1_ru.ts
we get:

Code: Select all

<TS version="2.1" language="ru_RU">
lupdate convert _ru ending from file name to value language="ru_RU" in ts file.

Maybe end of file names lead to error?
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

No, the error was just that the base *.ts actually contained translations. I just pushed a PR that removes those extraneous lines, and successfully merges the C++ and Python strings into a single TS file. Now Yorik needs to check it, and then push it to CrowdIn.

https://github.com/FreeCAD/FreeCAD/pull/5078
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Translation in FEM

Post by Evgeniy »

Good!
User avatar
chennes
Veteran
Posts: 3884
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translation in FEM

Post by chennes »

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. So I can modify the updatets.py script to remove them, I suppose.
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply