I am adding translation into my addon using:

def register():
    bpy.app.translations.register(__name__, translate.translation_dict) 

It throws back a ValueError:

translations message cache already contains some data for addon '__main__'

enter image description here

Googled around but can't find anything similar. Can't figure out what it meant and how to dealt with.

Something to do with cached data that can be deleted?

  • 1
    $\begingroup$ If you are running this from the text editor then __name__ == "__main__" either install as an addon and reload the script or hardcode in your addon name to test. $\endgroup$ – batFINGER May 20 '18 at 14:31
  • $\begingroup$ It works now. Then, do I hv to remove this line of code when i actually package this addon for others to use? or do i just leave it there? $\endgroup$ – adrian li May 21 '18 at 19:40
  • $\begingroup$ @batFINGER I tried to reload with F8, but still not working. I am using text editor inside Blender, what else should i check? I am running the register() inside if __name__ == "__main__": $\endgroup$ – adrian li May 30 '18 at 18:46
  • $\begingroup$ If the addon is registered as an addon (when you enable an addon it is imported from the addon folder "the_addons_name", then __name__ == "the_addons_name" and henceforth __name__ == "__main__" is false. It's True when run from text editor. Have you tried calling bpy.app.translations.unregister("__main__") ? ... you really want to be loading as an addon and not running from text editor. $\endgroup$ – batFINGER May 30 '18 at 19:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.