I would like to switch between English and Chinese translation with a shortcut (Alt+E), and have it affect interface as well as tooltips and new objects (only translating tooltips such as recommended here would not be enough in my case: Can I display two language for ui in Blender at the same time?) I hope to achieve it with this script:
import bpy
class OBJECT_OT_CustomOp(bpy.types.Operator):
"""Tooltip"""
bl_idname = "object.simple_operator"
bl_label = "Simple Object Operator"
def execute(self, context):
#bpy.context.preferences.view.language = 'zh_CN'
bpy.context.preferences.view.language = 'en_US'
return {'FINISHED'}
So far, I have been manually running the line with the language I wanted to use. I couldn't figure out how to assign the shortcut, since it is in the user preferences. The upper part is copied from the operator simple template. As I am new to Python, all help is appreciated, Thank you!