Question about coding standards or conventions, specifically strings enclosed by '_(' and ')'

I have been making some changes to the Relationship Graph report (gramps\plugins\graph\gvrelgraph.py). While editing the source code I noticed that a large number of strings in this file are enclosed by ‘_(‘ and ‘)’. For example on line 85:

_(“Color fill”)

I looked in the Gramps programming guidelines and PEP 8 webpages and I don’t see this convention described anywhere (but I could have overlooked it). Is this something which is recommended by the current Gramps maintainers, something which was done in the past and is no longer recommended, or just something unique to this file?

I have been doing a lot of enhancements to my version of the Relationship Graph report source code. I plan to offer my changes at sometime in the future as an “enhanced relationship graph” plugin. Along with my enhancements I have been making the code more understandable and maintainable (at least in my opinion, but I am somewhat biased in favor of my opinions :slight_smile: ). I would like to remove the ‘_(‘ and ‘)’ surrounding the strings but don’t want to do that if it goes against the Gramps coding guidelines and conventions.

I also haven’t run Black or pylint yet against my code but will do that sometime in the future.

Looking forward to hearing from the community on this question.

Note: I am running AIO64-6.0.3–1 on Windows.

It is used to provide string translation using the gettext module.

This is documented in the Coding for translation using weblate page in our wiki.

2 Likes

Thanks for the quick reply. I certainly want to follow this convention for supporting translations into other languages. Thanks.

1 Like