I have 2 new requirements for my addon and am wondering which is the best way to do this.
I would like to extend the functionality of:
layout label
– so it will have the same auto language translate capabilities of a layout operator
and
layout operator
– so that the text can be left justified rather than the default center justified situation
I have had a look at the cookbook stuff.
Would this be the best solution or do something in the C code, or use a mixin to extend the class (I’m not sure this would even work as it’s pretty much mixing C code and a Python class one AFAIK -could be wrong often am- )
There is no real auto-translate, it rather happens accidentally if your label is identical to a translated string and also the context it is in needs to match. It can be explicitly disabled by layout.label(…, translate=False), it is True by default:
Thanks CoDEmanX
I wanted left alignment in a button like it is in the label so all I am trying to do is make a button act like a label currently does.
Also, sorry I missed the bit in the docs Translate=True
The context bit then is what I need to work out.
I am using strings directly from the code ie tooltips or descriptions so there should be translations available. Maybe I need to duplicate the pattern match process to grep out the individual chunks from the translation files. What I am finding is individual words like Tooltip will auto work but a tooltip phrase doesn’t seem to.
I just thought that maybe if I separate them into single line phrases (currently I am using textwrap to make them fit visually) it might work.
I will try it and edit this post accordingly.
–update–
Nope that didn’t work. (I was going to use German as an example however the word Tooltip is not translated in the German version it works in Spanish so I used that instead)
Here’s the menu version
It is a one line label. I guess I have to do it manually.
The word Tooltip is translated but not the phrase.
Tooltip: won’t work however.
Also Tooltip will work even if there are other phrases on the same line.
Manually would probably be best so that I can still use textwrap to make the lines fit the box.
If you know where in the C or python the language search algorithm is that would help me greatly. If not I will track it down.