Not sure how you would localize everything though. You could just have a few supported languages and get the user language, then change the strings based on that.
Edit: Actually a better method, do node_tree.nodes[index].type and you’ll get a name like “BSDF_DIFFUSE”, that doesn’t change with the user language.
Thanks for the input! I thought about both of these before, but neither really helps. Checking for the language would still require I manually support all kinds of languages and their different terms.
Iterating over all nodes and checking for their types may work for nodes themselves, but this doesn’t work for their inputs. Also, iterating till you find a type seems really inefficient compared to straight selecting nodes (by name). It also doesn’t provide a way to distinguish between nodes of the same type.
You can of course also address nodes and their inputs via their indices, but that’s far from ideal and error prone.
I’m quite surprised there doesn’t seem to be a good way to deal with this.
The best approach is probably to not rely on any existing nodes (as in a newly created material) and instead always create all nodes from scratch. Unfortunately that still doesn’t take care of node input names.
Thanks for the input! I thought about both of these before, but neither really helps. Checking for the language would still require I manually support all kinds of languages and their different terms.
Iterating over all nodes and checking for their types may work for nodes themselves, but this doesn’t work for their inputs. Also, iterating till you find a type seems really inefficient compared to straight selecting nodes (by name). It also doesn’t provide a way to distinguish between nodes of the same type.
You can of course also adress nodes and their inputs via their indices, but that’s far from ideal and error prone.
I’m quite surprised there doesn’t seem to be a good way to deal with this.
The best approach is probably to not rely on any existing nodes (as in a newly created material) and instead always create all nodes from scratch. Unfortunately that still doesn’t take care of node input names.
Maybe playing around with bpy.app.translations, and the modules in the scripts/modules/bl_i18_utils/* ?!
I never digged that much into the translations part of blender, but I think you can get a translation to the default ‘en-us’ from the active language.
Thanks, I’ve looked but didn’t find much. Since blender is able to do the mapping for different languages, it would be great to have a function to do the reverse mapping.
B.Y.O.B
(Node Preview and LuxCore Addon Developer)
7