Python modules generated by the extension wizard are using the ‘_()’ function for strings to be translated.
The simple use case is obvious: _(“T e x t”).
How do we mark formatted strings with runtime place holders?
f"Diameter ({lengthUnit})"
By the way, what about strings in the widget managed by designer? Are they marked as translatable by default? Does the dev need to perform some special steps?
The .ui files should be fine in general with a few caveats described in the document.
For python, we need to avoid the f string interpolation method for translatable strings because the part in {} is executable python code, and we don’t want people to be able to use that to inject incorrect behaviour via the translation files. Instead we need to use the named placeholder method of formatting.
Also people providing translations should be aware that these placeholders inside the {} blocks need to be left alone or the code can break. Maybe weblate or something warns about this, I’m not sure.
Small nitpick, python style usually omits the spaces around the = sign so you may get style warnings about it.
@chir.set if the document did not answer any of your questions or not clear enough then please submit a pull request to add/change the text. If needed then of course you can ask due clarification here.
I’m not sure that we have a similar understanding of the problem; I’ll push a branch in SlicerVMTK with changes I have made regarding translation and we’ll discuss in a PR over there.
After translating SlicerVMTK to French, I merged #111 to fix some inconsistencies.
Weblate does not seem to pickup updates from the code base on its own. How do the translatable strings get updated in weblate? Is it automated on Slicer’s side? Is it done manually on a scheduled basis?