How to work with system/user parameters.

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!
User avatar
Kuzma30
Posts: 163
Joined: Wed Oct 24, 2018 11:50 am
Location: Ukraine

Re: How to work with system/user parameters.

Post by Kuzma30 »

Thanks I will try to prepare PR for review with translation in App.
RealThunder's A3 Wiki translation, join the project https://crowdin.com/project/freecad-asm3-wiki
User avatar
adrianinsaval
Veteran
Posts: 5551
Joined: Thu Apr 05, 2018 5:15 pm

Re: How to work with system/user parameters.

Post by adrianinsaval »

adrianinsaval wrote: Sat Jul 09, 2022 4:31 pm according to this post: https://forum.freecadweb.org/viewtopic. ... 30#p600030 it might be possible to translate stuff at the App level now.
@yorik @wmayer could you guys confirm this?
Kuzma30 wrote: Sat Jul 09, 2022 6:01 pm Thanks I will try to prepare PR for review with translation in App.
It might be necessary to remove the "Unnamed" argument from all those lines you mentioned in my PR so they will just use the function's default value that would be translated.
User avatar
Kuzma30
Posts: 163
Joined: Wed Oct 24, 2018 11:50 am
Location: Ukraine

Re: How to work with system/user parameters.

Post by Kuzma30 »

adrianinsaval wrote: Sat Jul 09, 2022 9:01 pm
adrianinsaval wrote: Sat Jul 09, 2022 4:31 pm according to this post: https://forum.freecadweb.org/viewtopic. ... 30#p600030 it might be possible to translate stuff at the App level now.
@yorik @wmayer could you guys confirm this?
Kuzma30 wrote: Sat Jul 09, 2022 6:01 pm Thanks I will try to prepare PR for review with translation in App.
It might be necessary to remove the "Unnamed" argument from all those lines you mentioned in my PR so they will just use the function's default value that would be translated.
I prepare PR
https://github.com/FreeCAD/FreeCAD/pull/7156
RealThunder's A3 Wiki translation, join the project https://crowdin.com/project/freecad-asm3-wiki
wmayer
Founder
Posts: 20309
Joined: Thu Feb 19, 2009 10:32 am
Contact:

Re: How to work with system/user parameters.

Post by wmayer »

Kuzma30 wrote: Sun Jul 10, 2022 7:03 am I prepare PR
https://github.com/FreeCAD/FreeCAD/pull/7156
This is the wrong way and it causes a (minor) regression because if only the first argument is passed the Label will always be set to the translation of "Unnamed" and this is not what (macro) programmers want to have.

Example:

Code: Select all

doc = App.newDocument("This_is_a_special_name")
doc.Label # => This is not "This_is_a_special_name" but "Unnamed"
In order to avoid to set up the translation files in all App modules you can add a function getDefaultDocumentName:

Code: Select all

std::string Application::getDefaultDocumentName()
{
    QString name = QObject::tr("Unnamed");
    return name.toStdString();
}
For the calling instances of newDocument() you have to write:

Code: Select all

App::GetApplication().newDocument(App::GetApplication().getDefaultDocumentName().c_str())
But note:
On many systems the translation of "Unnamed" will contain non-7-bit ASCII characters and at the moment each of them will be replaced with '_'. So, in the worst case you can end up with a document name "____________".

Since Py3 supports unicode for its identifiers we can make this less restrictive for our internal names (documents and document objects), too.
User avatar
Kuzma30
Posts: 163
Joined: Wed Oct 24, 2018 11:50 am
Location: Ukraine

Re: How to work with system/user parameters.

Post by Kuzma30 »

wmayer wrote: Mon Jul 11, 2022 11:55 am
Kuzma30 wrote: Sun Jul 10, 2022 7:03 am I prepare PR
https://github.com/FreeCAD/FreeCAD/pull/7156
This is the wrong way and it causes a (minor) regression because if only the first argument is passed the Label will always be set to the translation of "Unnamed" and this is not what (macro) programmers want to have.

Example:

Code: Select all

doc = App.newDocument("This_is_a_special_name")
doc.Label # => This is not "This_is_a_special_name" but "Unnamed"
Thanks. I understand my mistake.
Please review this https://github.com/FreeCAD/FreeCAD/pull ... 9b2c93ae48
RealThunder's A3 Wiki translation, join the project https://crowdin.com/project/freecad-asm3-wiki
Post Reply