I have what is probably a very basic question. If you compare the following snippets of the register call from two different python plug-ins, the "description" parameter for each is worded differently. But when you run the plug-ins the GUI that "pops" up looks pretty much the same for each.
My question is, what is the purpose/effect of the leading underscore and the parentheses in the second snippet?
register(
...,
[
(PF_STRING, "widgetcontainer_name", "File Name", "layout.txt"),
(PF_DIRNAME, "out_dirname", "Output Directory", ""),
...)
compared with:
register(
...,
[
(PF_DIRNAME, "indirectory", _("Input Directory"), os.getcwd() ),
(PF_DIRNAME, "outdirectory", _("Output Directory"), os.getcwd() ),
(PF_OPTION, "ext", _("Extension"), 0, ["JPEG", "GIF", "PNG"]),
(PF_SPINNER, "new_long_side", _("New long side (px):"), 640, (10, 3000, 1)),
(PF_OPTION, "interpolation", _("Interpolation"), 3, ["None", "Linear", "Cubic", "Lanczos"]),
],
...)
It is meant for translations
foo(anything) calls a function named "foo" to operate on the data in "anything".
A function name can be any combination of letters, digits, and underscore (digits aren't allowed as the first character in the name).
So you can define function called "_" and use is as "_()".
In practice it is usually defined as a function that finds the translated version (as required by the user's language) of the argument string , if it exists and otherwise returns the original string.