Translations without source in FreeCAD.ts

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Translations without source in FreeCAD.ts

Post by Evgeniy »

From FreeCAD_ru.ts
<context>
<name>Gui::Dialog::AboutApplication</name>
<message>
<source>About</source>
<translation>О программе</translation>
</message>
<message>
<source>Revision number</source>
<translation>Номер редакции</translation>
</message>
<message>
<source>Version</source>
<translation>Версия</translation>
</message>
<message>
<source>OK</source>
<translation>OK</translation>
</message>
<message>
<source/>
<translation>О программе</translation>

</message>
<message>
<source>Release date</source>
<translation>Дата выпуска</translation>
</message>
<message>
<source>Copy to clipboard</source>
<translation>Скопировать в буфер обмена</translation>
</message>
<message>
<source>Operating system</source>
<translation>Операционная система</translation>
</message>
<message>
<source>Word size</source>
<translation>Размер слова</translation>
</message>
<message>
<source>License</source>
<translation>Лицензия</translation>
</message>
</context>
If the translation does not have a <source></source>, can it be used for translation?
looks like mistake.

17 strings of this form presented in FreeCAD.ts. In other *.ts files this strings are not presented.

№, file , context
1, 'FreeCAD.ts', 'Gui::Dialog::AboutApplication'
2, 'FreeCAD.ts', 'Gui::Dialog::DlgActivateWindow'
3, 'FreeCAD.ts', 'Gui::Dialog::DlgAuthorization'
4, 'FreeCAD.ts', 'Gui::Dialog::DlgCustomCommands'
5, 'FreeCAD.ts', 'Gui::Dialog::DlgCustomKeyboard'
6, 'FreeCAD.ts', 'Gui::Dialog::DlgCustomToolbars'
7, 'FreeCAD.ts', 'Gui::Dialog::DlgDisplayProperties'
8, 'FreeCAD.ts', 'Gui::Dialog::DlgEditorSettings'
9, 'FreeCAD.ts', 'Gui::Dialog::DlgInputDialog'
10, 'FreeCAD.ts', 'Gui::Dialog::DlgMaterialProperties'
11, 'FreeCAD.ts', 'Gui::Dialog::DlgPreferences'
12, 'FreeCAD.ts', 'Gui::Dialog::DlgProjectInformation'
13, 'FreeCAD.ts', 'Gui::Dialog::DlgReportView'
14, 'FreeCAD.ts', 'Gui::Dialog::DlgSettings3DView'
15, 'FreeCAD.ts', 'Gui::Dialog::DlgSettingsColorGradient'
16, 'FreeCAD.ts', 'Gui::Dialog::DlgTipOfTheDay'
17, 'FreeCAD.ts', 'Gui::DlgTreeWidget'
Last edited by Evgeniy on Tue Sep 28, 2021 7:12 am, edited 2 times in total.
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: For what needs translations without source?

Post by chennes »

Definitely seems like a mistake. Here's retranslateUi() for the About dialog:

Code: Select all

    void retranslateUi(QDialog *Gui__Dialog__AboutApplication)
    {
        Gui__Dialog__AboutApplication->setWindowTitle(QCoreApplication::translate("Gui::Dialog::AboutApplication", "About", nullptr));
        okButton->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "OK", nullptr));
        labelSplashPicture->setText(QString());
        labelOS->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Operating system", nullptr));
        labelPlatform->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Word size", nullptr));
        labelDate->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Release date", nullptr));
        labelRevision->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Revision number", nullptr));
        labelVersion->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Version", nullptr));
        copyButton->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Copy to clipboard", nullptr));
        tabWidget->setTabText(tabWidget->indexOf(tab_about), QCoreApplication::translate("Gui::Dialog::AboutApplication", "About", nullptr));
        tabWidget->setTabText(tabWidget->indexOf(tab_license), QCoreApplication::translate("Gui::Dialog::AboutApplication", "License", nullptr));
    } // retranslateUi
All of those calls to translate look fine, and the thing I suspected was the culprit (the picture) doesn't have a translate call on it.
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: For what needs translations without source?

Post by Evgeniy »

chennes wrote: Tue Sep 28, 2021 2:09 am Definitely seems like a mistake. Here's retranslateUi() for the About dialog:

Code: Select all

    void retranslateUi(QDialog *Gui__Dialog__AboutApplication)
    {
        Gui__Dialog__AboutApplication->setWindowTitle(QCoreApplication::translate("Gui::Dialog::AboutApplication", "About", nullptr));
        okButton->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "OK", nullptr));
        labelSplashPicture->setText(QString());
        labelOS->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Operating system", nullptr));
        labelPlatform->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Word size", nullptr));
        labelDate->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Release date", nullptr));
        labelRevision->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Revision number", nullptr));
        labelVersion->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Version", nullptr));
        copyButton->setText(QCoreApplication::translate("Gui::Dialog::AboutApplication", "Copy to clipboard", nullptr));
        tabWidget->setTabText(tabWidget->indexOf(tab_about), QCoreApplication::translate("Gui::Dialog::AboutApplication", "About", nullptr));
        tabWidget->setTabText(tabWidget->indexOf(tab_license), QCoreApplication::translate("Gui::Dialog::AboutApplication", "License", nullptr));
    } // retranslateUi
All of those calls to translate look fine, and the thing I suspected was the culprit (the picture) doesn't have a translate call on it.

picture... you say about that?:

Code: Select all

labelSplashPicture->setText(QString());
It is very strange that lupdate capture QString() to ts file...

Can you add link to source code on githab? I can't find where this place is.

For example i convert https://github.com/FreeCAD/FreeCAD/blob ... ication.ui
to ts file. result is ok:

Code: Select all

<context>
    <name>Gui::Dialog::AboutApplication</name>
    <message>
        <location filename="AboutApplication.ui" line="14"/>
        <location filename="AboutApplication.ui" line="57"/>
        <source>About</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="44"/>
        <source>OK</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="158"/>
        <source>Operating system</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="165"/>
        <source>Word size</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="179"/>
        <source>Release date</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="207"/>
        <source>Revision number</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="221"/>
        <source>Version</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="255"/>
        <source>Copy to clipboard</source>
        <translation type="unfinished"></translation>
    </message>
    <message>
        <location filename="AboutApplication.ui" line="291"/>
        <source>License</source>
        <translation type="unfinished"></translation>
    </message>
</context>
https://github.com/FreeCAD/FreeCAD/blob ... dowImp.cpp
does not have anomaly too...

Code: Select all

<context>
    <name>DlgActivateWindowImp</name>
    <message>
        <location filename="DlgActivateWindowImp.cpp" line="55"/>
        <source>Windows</source>
        <translation type="unfinished"></translation>
    </message>
</context>
<context>
    <name>Gui::Dialog::DlgActivateWindow</name>
    <message>
        <location filename="DlgActivateWindowImp.cpp" line="53"/>
        <source>&amp;Activate</source>
        <translation type="unfinished"></translation>
    </message>
</context>
I interesting what the https://github.com/FreeCAD/FreeCAD/pull/5037 will show...
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Translations without source in FreeCAD.ts

Post by Evgeniy »

Im look this post: https://forum.freecadweb.org/viewtopic. ... 20#p537065

And I make simple test for check other files:

Code: Select all

import re,codecs

path = "M:\FreeCAD-master"

def scanfile(path):
   file = open(path, "r", encoding="utf8");text=file.read();file.close()
   if "<translation>" in text:
      print(f"File {path} contains translations!")
   else:
      print(f"{path} Ok!")
   Gui.updateGui()

# Walk into FreeCAD unzipped folder
for dirpath, subdirs, files in os.walk(path):
   for file in files:
      if file.endswith(".ts") and "_" not in file:
         file_path = os.path.join(dirpath, file)
         scanfile(file_path)

# End
Result is:

Code: Select all

File M:\FreeCAD-master\src\Gui\Language\FreeCAD.ts contains translations!
M:\FreeCAD-master\src\Mod\AddonManager\Resources\translations\AddonManager.ts Ok!
M:\FreeCAD-master\src\Mod\Arch\Resources\translations\Arch.ts Ok!
M:\FreeCAD-master\src\Mod\Assembly\Gui\Resources\translations\Assembly.ts Ok!
M:\FreeCAD-master\src\Mod\Draft\Resources\translations\Draft.ts Ok!
M:\FreeCAD-master\src\Mod\Drawing\Gui\Resources\translations\Drawing.ts Ok!
File M:\FreeCAD-master\src\Mod\Fem\Gui\Resources\translations\Fem.ts contains translations!
M:\FreeCAD-master\src\Mod\Image\Gui\Resources\translations\Image.ts Ok!
M:\FreeCAD-master\src\Mod\Mesh\Gui\Resources\translations\Mesh.ts Ok!
M:\FreeCAD-master\src\Mod\MeshPart\Gui\Resources\translations\MeshPart.ts Ok!
M:\FreeCAD-master\src\Mod\OpenSCAD\Resources\translations\OpenSCAD.ts Ok!
M:\FreeCAD-master\src\Mod\Part\Gui\Resources\translations\Part.ts Ok!
M:\FreeCAD-master\src\Mod\PartDesign\Gui\Resources\translations\PartDesign.ts Ok!
M:\FreeCAD-master\src\Mod\Path\Gui\Resources\translations\Path.ts Ok!
M:\FreeCAD-master\src\Mod\Points\Gui\Resources\translations\Points.ts Ok!
M:\FreeCAD-master\src\Mod\Raytracing\Gui\Resources\translations\Raytracing.ts Ok!
M:\FreeCAD-master\src\Mod\ReverseEngineering\Gui\Resources\translations\ReverseEngineering.ts Ok!
M:\FreeCAD-master\src\Mod\Robot\Gui\Resources\translations\Robot.ts Ok!
M:\FreeCAD-master\src\Mod\Sketcher\Gui\Resources\translations\Sketcher.ts Ok!
M:\FreeCAD-master\src\Mod\Spreadsheet\Gui\Resources\translations\Spreadsheet.ts Ok!
M:\FreeCAD-master\src\Mod\Start\Gui\Resources\translations\StartPage.ts Ok!
M:\FreeCAD-master\src\Mod\TechDraw\Gui\Resources\translations\TechDraw.ts Ok!
M:\FreeCAD-master\src\Mod\Test\Gui\Resources\translations\Test.ts Ok!
M:\FreeCAD-master\src\Mod\Tux\Resources\translations\Tux.ts Ok!
M:\FreeCAD-master\src\Mod\Web\Gui\Resources\translations\Web.ts Ok!
That shows FreeCAD.ts have garbage too.
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: Translations without source in FreeCAD.ts

Post by Evgeniy »

And In freecad.ts i found these empty translations. A few pieces.

Code: Select all

    <message>
        <source></source>
        <translation></translation>
    </message>
User avatar
chennes
Veteran
Posts: 3876
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: Translations without source in FreeCAD.ts

Post by chennes »

I've added a change to updatets.py to automatically strip out any translation strings it finds in the base TS files: they can't get used anyway, there is no language specified for those files. See https://github.com/FreeCAD/FreeCAD/pull/5078
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply