This commit is contained in:
2025-05-08 00:39:41 +08:00
parent 1bc836fafa
commit 24acc2a6f1
17 changed files with 1464 additions and 1388 deletions

View File

@@ -3,10 +3,321 @@
"""
Localization module
本地化模块 - 提供UI文本的多语言支持
"""
import maya.cmds as cmds
import config
# 当前选择的语言
current_language = config.TOOL_LANG # 默认使用中文
# 语言字典
LANG = {
"en_US": {
# 主界面
"geometry": "Geometry",
"rigging": "Rigging",
"behaviour": "Behaviour",
"definition": "Definition",
# 几何体模块
"geometry_title": "Geometry",
"clean": " Clean ",
"load": "Load mesh",
"clear_all_models": " Clean all models",
"add_model": "Add Model",
"remove_model": "Remove Model",
"duplicate_model": "Duplicate Model",
"model_properties": "Model Properties",
"model_tools": "Model Tools",
"name": "Name",
"enter_model_name": "Enter Model Name",
"type": "Type",
"visible": "Visible",
"apply": "Apply",
"reset": "Reset",
"topology_structure": "Topology Structure",
"select_lod": "Select LOD",
"all": "All",
"create_lod": "Create LOD",
"separate_model": "Separate Model",
"generate_face_components": "Generate Face Components",
"fix_point_order": "Fix point order",
"fix_normals": "Fix normal",
"fix_vertex_order": "Fix vertex order",
"fix_seams": "Fix seams",
"standardize_naming": "Standardize Naming",
"optimize_scene": "Optimize Scene",
"auto_group": "Auto Group",
"create_custom_lod": "Create Custom LOD",
"import_lod": "Import LOD",
"export_lod": "Export LOD",
"search": "Search...",
# 绑定模块
"rigging_title": "Rigging System",
"presets": "Presets",
"assets": "Assets",
"descriptor": "Descriptor",
"project_path": "Project Path",
"Presets DNA:": "Presets DNA:",
"gender": "Gender",
"age": "Age",
"translation_unit": "Translation Unit",
"rotation_unit": "Rotation Unit",
"coordinate_system": "Coordinate System",
"lod_count": "LOD Count",
"archetype": "Archetype",
"import_skeleton": "Import Skeleton",
"build_rigging": "Build Rigging",
"remove_all": "Remove All",
# 行为模块
"behaviour_title": "Behaviour System",
"search": "Search...",
" Range - ": " Range - ",
" Range + ": " Range + ",
"Raw Control": "Raw Control",
"Related BlendShapes": "Related BlendShapes",
"Add": "Add",
"Delete": "Delete",
"Batch": "Batch",
"Rebuild": "Rebuild",
"Reposition": "Reposition",
"Blend": "Blend",
"Flip Target": "Flip Target",
"Mirror Target": "Mirror Target",
"Find Flip Target": "Find Flip Target",
"Add BlendShape": "Add BlendShape",
"Delete BlendShape": "Delete BlendShape",
"Batch BlendShape": "Batch BlendShape",
"Rebuild Select": "Rebuild Select",
"Reposition Joints": "Reposition Joints",
"Blend Select": "Blend Select",
"Reset Default": "Reset Default",
"Find Select": "Find Select",
"Write Current": "Write Current",
"Controller Find": "Controller Find",
"Select Joint": "Select Joint",
"Find Mirror": "Find Mirror",
# 定义模块
"definition_title": "Definition System",
"lods": "LODs",
"meshes": "Meshes",
"bones": "Bones",
"name_pattern": "Name Pattern",
"expression": "Expression",
"add_lod": "Add LOD",
"remove_lod": "Remove LOD",
"duplicate_lod": "Duplicate LOD",
"add_mesh": "Add Mesh",
"remove_mesh": "Remove Mesh",
"duplicate_mesh": "Duplicate Mesh",
"add_bone": "Add Bone",
"remove_bone": "Remove Bone",
"duplicate_bone": "Duplicate Bone",
"import_definition": "Import Definition",
"export_definition": "Export Definition",
# 工具栏
"Save DNA": "Save DNA",
"Open DNA": "Open DNA",
"Create RL4 node": "Create RL4 Node",
"Delete RL4 node": "Delete RL4 Node",
"Import skin": "Import Skin",
"Export skin": "Export Skin",
"Copy skin": "Copy Skin",
"Switch language": "Switch Language",
"Help": "Help"
},
"zh_CN": {
# 主界面
"geometry": "几何体",
"rigging": "绑定",
"behaviour": "行为",
"definition": "定义",
# 几何体模块
"geometry_title": "几何模型",
"clean": " 清 理 ",
"load": " 加 载 ",
"clear_all_models": " 清理所有模型",
"add_model": "添加模型",
"remove_model": "移除模型",
"duplicate_model": "复制模型",
"model_properties": "模型属性",
"model_tools": "模型工具",
"name": "名称",
"enter_model_name": "输入模型名称",
"type": "类型",
"visible": "可见",
"apply": "应用",
"reset": "重置",
"topology_structure": "拓扑结构",
"select_lod": "选择LOD",
"all": "全部",
"create_lod": "创建LOD",
"separate_model": "模型分离",
"generate_face_components": "生成面部配件",
"fix_point_order": "修复点序",
"fix_normals": "修复法线",
"fix_vertex_order": "修复点序",
"fix_seams": "修复接缝",
"standardize_naming": "标准化命名",
"optimize_scene": "优化场景",
"auto_group": "自动分组",
"create_custom_lod": "创建自定义LOD",
"import_lod": "导入LOD",
"export_lod": "导出LOD",
"search": "搜索...",
# 绑定模块
"rigging_title": "绑定系统",
"presets": "预设",
"assets": "资源",
"descriptor": "描述器",
"project_path": "项目路径",
"Presets DNA:": "预设 DNA:",
"gender": "性别",
"age": "年龄",
"translation_unit": "平移单位",
"rotation_unit": "旋转单位",
"coordinate_system": "坐标系统",
"lod_count": "LOD数量",
"archetype": "原型",
"import_skeleton": "导入骨骼",
"build_rigging": "创建绑定",
"remove_all": "移除全部",
# 行为模块
"behaviour_title": "行为系统",
"search": "搜索...",
" Range - ": " 范围 - ",
" Range + ": " 范围 + ",
"Raw Control": "原始控制",
"Related BlendShapes": "相关形态混合",
"Add": "添加",
"Delete": "删除",
"Batch": "批量",
"Rebuild": "重建",
"Reposition": "重定位",
"Blend": "混合",
"Flip Target": "翻转目标",
"Mirror Target": "镜像目标",
"Find Flip Target": "查找翻转目标",
"Add BlendShape": "添加形态混合",
"Delete BlendShape": "删除形态混合",
"Batch BlendShape": "批量形态混合",
"Rebuild Select": "重建选择",
"Reposition Joints": "重定位关节",
"Blend Select": "混合选择",
"Reset Default": "重置默认",
"Find Select": "查找选择",
"Write Current": "写入当前",
"Controller Find": "查找控制器",
"Select Joint": "选择关节",
"Find Mirror": "查找镜像",
# 定义模块
"definition_title": "定义系统",
"lods": "级别细节",
"meshes": "网格",
"bones": "骨骼",
"name_pattern": "命名模式",
"expression": "表情",
"add_lod": "添加LOD",
"remove_lod": "移除LOD",
"duplicate_lod": "复制LOD",
"add_mesh": "添加网格",
"remove_mesh": "移除网格",
"duplicate_mesh": "复制网格",
"add_bone": "添加骨骼",
"remove_bone": "移除骨骼",
"duplicate_bone": "复制骨骼",
"import_definition": "导入定义",
"export_definition": "导出定义",
# 工具栏
"保存DNA": "保存DNA",
"打开DNA": "打开DNA",
"创建RL4节点": "创建RL4节点",
"删除RL4节点": "删除RL4节点",
"导入蒙皮": "导入蒙皮",
"导出蒙皮": "导出蒙皮",
"复制蒙皮": "复制蒙皮",
"切换语言": "切换语言",
"帮助": "帮助"
}
}
}
def get_text(key, default=None):
"""
获取当前语言的文本
Args:
key: 文本键名
default: 如果找不到对应文本,返回的默认值
Returns:
str: 当前语言对应的文本
"""
global current_language
if not default:
default = key
# 如果key在当前语言中存在返回翻译文本
if key in LANG.get(current_language, {}):
return LANG[current_language][key]
# 如果只在英文中存在,返回英文
if key in LANG.get("en_US", {}):
return LANG["en_US"][key]
# 否则返回默认值
return default
def switch_language():
"""
切换当前语言
在中文和英文之间切换
Returns:
str: 切换后的语言代码
"""
global current_language
# 切换语言
if current_language == "zh_CN":
current_language = "en_US"
print("已切换到英文界面")
else:
current_language = "zh_CN"
print("已切换到中文界面")
return current_language
def get_current_language():
"""
获取当前语言代码
Returns:
str: 当前语言代码
"""
return current_language
def set_language(lang_code):
"""
设置当前语言
Args:
lang_code: 语言代码,如'zh_CN''en_US'
Returns:
bool: 是否设置成功
"""
global current_language
if lang_code in LANG:
current_language = lang_code
return True
return False