SpreadSheet "Command" translation

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
Post Reply
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

SpreadSheet "Command" translation

Post by Evgeniy »

For what is needs to translate strings with context "Command" and where this text will be displayed?
Is it something to do with programming?

CmdTrans.png
CmdTrans.png (52.57 KiB) Viewed 1740 times
Last edited by Evgeniy on Tue Aug 24, 2021 7:29 am, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: SpreadSheet "Command" translation

Post by Kunda1 »

Evgeniy wrote: Mon Aug 23, 2021 2:36 pm For what is needs to translate strings with context "Command" and where this text will be displayed?
It most likely has to do with the programmer who coded this part of the code didn't add an appropriate context assigned the 'Command' context to it (which is quite common in the source code)

Code: Select all

translate("context", "My text")
Edit:
Here it is in the code:

Code: Select all

            Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Clear cell(s)"));
source: https://github.com/FreeCAD/FreeCAD/blob ... w.cpp#L161

Edit2: It seems like assigning 'Command' in the source as a context is quite common. Not sure why
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: SpreadSheet "Command" translation

Post by Evgeniy »

Im see this source code on github.
Maybe this is some kind of mistake...
It is not clear why this should be translated.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: SpreadSheet "Command" translation

Post by Kunda1 »

Oh I see, you think that the 'command' string is part of the translation?? If so then, no it's not!
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: SpreadSheet "Command" translation

Post by Evgeniy »

Kunda1 wrote: Mon Aug 23, 2021 8:23 pm Oh I see, you think that the 'command' string is part of the translation?? If so then, no it's not!
But in Crowdin are many of them. Look my screenshot in first message.

Code: Select all

Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Left-align cell"));
https://github.com/FreeCAD/FreeCAD/blob ... ommand.cpp
String 290

Code: Select all

Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Split cell"));

Code: Select all

Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Set underline text"));
etc...

Yorik add these lines to Crowdin in December 2020.
But it is not clear for what purpose it is needs translated. And what it is used for. The context of the translation is not clear.


Maybe this for invoke python commands in any languages, but Python code:

Code: Select all

import Spreadsheet
from PySide.QtCore import QT_TRANSLATE_NOOP
FreeCADGui.runCommand(QT_TRANSLATE_NOOP("Command", "Center cell"));
Does nothing effect...

When i tryed to complete the translation of the SpreadSheet, that confused me... Until there is a response from the developers, I think it's better not do the translate.
Last edited by Evgeniy on Tue Aug 24, 2021 6:46 pm, edited 1 time in total.
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: SpreadSheet "Command" translation

Post by Kunda1 »

We need a core dev to weigh in on this
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
User avatar
Evgeniy
Posts: 477
Joined: Thu Jul 15, 2021 6:10 pm

Re: SpreadSheet "Command" translation

Post by Evgeniy »

Kunda1 wrote: Tue Aug 24, 2021 3:37 pm We need a core dev to weigh in on this
This strings are used in the Undo menu (also in Redo menu).
Undo menu.png
Undo menu.png (10.28 KiB) Viewed 1375 times
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: SpreadSheet "Command" translation

Post by chennes »

Right -- the fact that it's called "openCommand()" might lead you to think it's trying to run the command that the string represents, in which case definitely the calls to translate would be wrong. But actually it's only using that text as the undo/redo string for the following lines of code. So in this case "Command" as the context is sort of ambiguous, but I don't know what would be better. Maybe we could use the disambiguation string argument to tr()? Does that show in CrowdIn?
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: SpreadSheet "Command" translation

Post by Evgeniy »

Yes, it would not hurt to correct the context. Just in case, I post a comment for string with this context in Crowdin.
User avatar
chennes
Veteran
Posts: 3914
Joined: Fri Dec 23, 2016 3:38 pm
Location: Norman, OK, USA
Contact:

Re: SpreadSheet "Command" translation

Post by chennes »

To be clear, I wasn't proposing to change the context (yet): I was suggesting we add an argument to tr(). It has an optional final argument that Qt calls the "disambiguation string". So we could write something like:

Code: Select all

Gui::Command::openCommand(QT_TRANSLATE_NOOP3("Command", "Left-align cell", "For undo/redo menu"));
Chris Hennes
Pioneer Library System
GitHub profile, LinkedIn profile, chrishennes.com
Post Reply