Results 1 to 5 of 5
  1. #1

    nodes in localized Blender versions

    What's the best approach to working with localized Blender versions and their localized naming of nodes and node inputs etc?

    Accessing the Diffuse BSDF node in a newly created material, you do
    Code:
    node_tree.nodes['Diffuse BSDF'].
    However, in Portuguese, the node would be called 'BSDF - Difuso' and so the above would fail.

    Similarly, the following would fail as well:

    Code:
    diffusenode.inputs['Roughness']'
    Because it's actually called 'Rugosidade' in Portuguese.

    Am I missing something obvious? I can't be expected to cover all language cases?

    I'd appreciate any input!
    Last edited by MACHIN3; 13-Nov-17 at 13:11.



  2. #2
    You can get the UI language by doing
    Code:
    bpy.context.user_preferences.system.language
    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.
    Last edited by Cyaoeu; 13-Nov-17 at 18:49. Reason: better method



  3. #3
    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.
    Last edited by MACHIN3; 14-Nov-17 at 04:42.



  4. #4
    Member Secrop's Avatar
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    1,894
    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.



  5. #5
    Originally Posted by Secrop View Post
    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.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •