Function Translations Complete

- Done Translations
- Added self.reports for Atlas Materials.
- Added self.reports for digitlgradelegs
This commit is contained in:
Yusarina
2024-07-25 03:13:17 +01:00
parent b6beae7ba1
commit fc69a22c62
9 changed files with 58 additions and 26 deletions
+4 -2
View File
@@ -119,8 +119,8 @@ def prep_images_in_scene(context: Context) -> list[MaterialImageList]:
class Atlas_Materials(Operator): class Atlas_Materials(Operator):
bl_idname = "avatar_toolkit.atlas_materials" bl_idname = "avatar_toolkit.atlas_materials"
bl_label = "Atlas Materials" bl_label = t("TextureAtlas.atlas_materials")
bl_description = "Atlas materials to optimize the model" bl_description = t("TextureAtlas.atlas_materials_desc")
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
@classmethod @classmethod
@@ -270,8 +270,10 @@ class Atlas_Materials(Operator):
mesh.materials.append(atlased_mat.material) mesh.materials.append(atlased_mat.material)
self.report({'INFO'}, t("TextureAtlas.atlas_completed"))
return {"FINISHED"} return {"FINISHED"}
except Exception as e: except Exception as e:
self.report({'ERROR'}, t("TextureAtlas.atlas_error"))
raise e raise e
return {"FINISHED"} return {"FINISHED"}
+3 -3
View File
@@ -71,7 +71,7 @@ class CombineMaterials(Operator):
def execute(self, context: Context) -> Set[str]: def execute(self, context: Context) -> Set[str]:
armature = get_selected_armature(context) armature = get_selected_armature(context)
if not armature: if not armature:
self.report({'WARNING'}, "No armature selected") self.report({'WARNING'}, t("Optimization.no_armature_selected"))
return {'CANCELLED'} return {'CANCELLED'}
context.view_layer.objects.active = armature context.view_layer.objects.active = armature
@@ -79,7 +79,7 @@ class CombineMaterials(Operator):
meshes = get_all_meshes(context) meshes = get_all_meshes(context)
if not meshes: if not meshes:
self.report({'WARNING'}, "No meshes found for the selected armature") self.report({'WARNING'}, t("Optimization.no_meshes_found"))
return {'CANCELLED'} return {'CANCELLED'}
self.consolidate_materials(meshes) self.consolidate_materials(meshes)
@@ -111,7 +111,7 @@ class CombineMaterials(Operator):
else: else:
mat_mapping[base_name] = mat mat_mapping[base_name] = mat
report_consolidated(self, num_combined) self.report({'INFO'}, t("Optimization.materials_combined").format(num_combined=num_combined))
def remove_unused_materials(self) -> None: def remove_unused_materials(self) -> None:
for mat in bpy.data.materials: for mat in bpy.data.materials:
+3 -1
View File
@@ -32,7 +32,7 @@ class CreateDigitigradeLegs(bpy.types.Operator):
digi2 = digi1.children[0] digi2 = digi1.children[0]
digi3 = digi2.children[0] digi3 = digi2.children[0]
except: except:
print("bone format incorrect! Please select a chain of 4 continious bones!") #TODO: Show this to user. this is an error. self.report({'ERROR'}, t('Tools.digitigrade_legs.error.bone_format'))
return {'CANCELLED'} return {'CANCELLED'}
digi4 = None digi4 = None
try: try:
@@ -114,4 +114,6 @@ class CreateDigitigradeLegs(bpy.types.Operator):
digi1.name = re.compile(re.escape("<noik>"), re.IGNORECASE).sub("",digi1.name)+"<noik>" digi1.name = re.compile(re.escape("<noik>"), re.IGNORECASE).sub("",digi1.name)+"<noik>"
digi2.name = re.compile(re.escape("<noik>"), re.IGNORECASE).sub("",digi2.name)+"<noik>" digi2.name = re.compile(re.escape("<noik>"), re.IGNORECASE).sub("",digi2.name)+"<noik>"
#finally fully done! #finally fully done!
self.report({'INFO'}, t('Tools.digitigrade_legs.success'))
return {'FINISHED'} return {'FINISHED'}
+1
View File
@@ -77,6 +77,7 @@ class ImportAnyModel(Operator, ImportHelper):
print("importer error was:") print("importer error was:")
print(e) print(e)
self.report({'INFO'}, t('Quick_Access.import_success'))
return {'FINISHED'} return {'FINISHED'}
+6 -7
View File
@@ -23,7 +23,7 @@ class JoinAllMeshes(Operator):
def join_all_meshes(self, context: Context) -> None: def join_all_meshes(self, context: Context) -> None:
if not select_current_armature(context): if not select_current_armature(context):
self.report({'WARNING'}, "No armature selected") self.report({'WARNING'}, t("Optimization.no_armature_selected"))
return return
armature = get_selected_armature(context) armature = get_selected_armature(context)
@@ -41,9 +41,9 @@ class JoinAllMeshes(Operator):
fix_uv_coordinates(context) fix_uv_coordinates(context)
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_all(action='DESELECT')
self.report({'INFO'}, "Meshes joined successfully") self.report({'INFO'}, t("Optimization.meshes_joined"))
else: else:
self.report({'WARNING'}, "No mesh objects selected") self.report({'WARNING'}, t("Optimization.no_mesh_selected"))
context.view_layer.objects.active = armature context.view_layer.objects.active = armature
@@ -66,7 +66,7 @@ class JoinSelectedMeshes(Operator):
selected_objects: List[Object] = [obj for obj in bpy.context.selected_objects if obj.type == 'MESH'] selected_objects: List[Object] = [obj for obj in bpy.context.selected_objects if obj.type == 'MESH']
if len(selected_objects) < 2: if len(selected_objects) < 2:
self.report({'WARNING'}, "Please select at least two mesh objects") self.report({'WARNING'}, t("Optimization.select_at_least_two_meshes"))
return return
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
@@ -82,7 +82,6 @@ class JoinSelectedMeshes(Operator):
fix_uv_coordinates(context) fix_uv_coordinates(context)
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_all(action='DESELECT')
self.report({'INFO'}, "Selected meshes joined successfully") self.report({'INFO'}, t("Optimization.selected_meshes_joined"))
else: else:
self.report({'WARNING'}, "No mesh objects selected") self.report({'WARNING'}, t("Optimization.no_mesh_selected"))
+5 -4
View File
@@ -6,7 +6,7 @@ from typing import List, Tuple, Optional, TypedDict
from bpy.types import Material, Operator, Context, Object from bpy.types import Material, Operator, Context, Object
from ..core.register import register_wrap from ..core.register import register_wrap
from ..core.common import get_selected_armature, is_valid_armature, select_current_armature, get_all_meshes from ..core.common import get_selected_armature, is_valid_armature, select_current_armature, get_all_meshes
from ..functions.translations import t
class meshEntry(TypedDict): class meshEntry(TypedDict):
mesh: bpy.types.Object mesh: bpy.types.Object
@@ -15,8 +15,8 @@ class meshEntry(TypedDict):
@register_wrap @register_wrap
class RemoveDoublesSafely(Operator): class RemoveDoublesSafely(Operator):
bl_idname = "avatar_toolkit.remove_doubles_safely" bl_idname = "avatar_toolkit.remove_doubles_safely"
bl_label = "Remove Doubles Safely" bl_label = t("Optimization.remove_doubles_safely.label")
bl_description = "Remove Doubles on all meshes, making sure to not fuse things like mouths together." bl_description = t("Optimization.remove_doubles_safely.desc")
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
objects_to_do: list[meshEntry] = [] objects_to_do: list[meshEntry] = []
merge_distance: bpy.props.FloatProperty(default=0.0001) merge_distance: bpy.props.FloatProperty(default=0.0001)
@@ -28,7 +28,7 @@ class RemoveDoublesSafely(Operator):
def execute(self, context: Context) -> set: def execute(self, context: Context) -> set:
if not select_current_armature(context): if not select_current_armature(context):
self.report({'WARNING'}, "No armature selected") self.report({'WARNING'}, t("Optimization.no_armature_selected"))
return {'CANCELLED'} return {'CANCELLED'}
armature = get_selected_armature(context) armature = get_selected_armature(context)
@@ -117,6 +117,7 @@ class RemoveDoublesSafely(Operator):
mesh["mesh"].select_set(False) mesh["mesh"].select_set(False)
else: else:
self.report({'INFO'}, t("Optimization.remove_doubles_completed"))
return {'FINISHED'} return {'FINISHED'}
return {'RUNNING_MODAL'} return {'RUNNING_MODAL'}
+3 -3
View File
@@ -22,7 +22,7 @@ class ConvertToResonite(Operator):
def execute(self, context: Context) -> set: def execute(self, context: Context) -> set:
armature = get_selected_armature(context) armature = get_selected_armature(context)
if not armature: if not armature:
self.report({'WARNING'}, "No armature selected") self.report({'WARNING'}, t("Tools.no_armature_selected"))
return {'CANCELLED'} return {'CANCELLED'}
translate_bone_fails = 0 translate_bone_fails = 0
@@ -107,8 +107,8 @@ class ConvertToResonite(Operator):
bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.mode_set(mode='OBJECT')
if translate_bone_fails > 0: if translate_bone_fails > 0:
self.report({'INFO'}, "Failed to translate {translate_bone_fails} bones to humanoid names. Adding \"<noik>\" to their names.".format(translate_bone_fails=translate_bone_fails)) self.report({'INFO'}, t("Tools.bones_translated_with_fails").format(translate_bone_fails=translate_bone_fails))
else: else:
self.report({'INFO'}, "Successfully translated all bones to humanoid names") self.report({'INFO'}, t("Tools.bones_translated_success"))
return {'FINISHED'} return {'FINISHED'}
-1
View File
@@ -63,7 +63,6 @@ class AutoVisemeButton(bpy.types.Operator):
print("Sorting shape keys...") print("Sorting shape keys...")
common.sort_shape_keys(mesh) common.sort_shape_keys(mesh)
print("Viseme creation completed.")
self.report({'INFO'}, t('AutoVisemeButton.success')) self.report({'INFO'}, t('AutoVisemeButton.success'))
return {'FINISHED'} return {'FINISHED'}
+33 -5
View File
@@ -1,5 +1,5 @@
{ {
"authors": ["Avatar Toolkit Team"], "authors": ["Avatar Toolkit Team"],
"messages": { "messages": {
"Language.auto": "Automatic", "Language.auto": "Automatic",
"Language.en_US": "English", "Language.en_US": "English",
@@ -24,6 +24,7 @@
"Quick_Access.select_export_resonite.label": "Resonite", "Quick_Access.select_export_resonite.label": "Resonite",
"Quick_Access.export_fbx.label": "Export FBX", "Quick_Access.export_fbx.label": "Export FBX",
"Quick_Access.export_fbx.desc": "Export the model as FBX", "Quick_Access.export_fbx.desc": "Export the model as FBX",
"Quick_Access.import_success": "Model imported successfully",
"Export.resonite.label": "Export to Resonite", "Export.resonite.label": "Export to Resonite",
"Export.resonite.desc": "Export a GLB with all animations and materials. For animation data see:", "Export.resonite.desc": "Export a GLB with all animations and materials. For animation data see:",
"Optimization.label": "Optimization", "Optimization.label": "Optimization",
@@ -35,19 +36,37 @@
"Optimization.join_selected_meshes.label": "Join Selected Meshes", "Optimization.join_selected_meshes.label": "Join Selected Meshes",
"Optimization.join_selected_meshes.desc": "Join all currently Selected Meshes into one", "Optimization.join_selected_meshes.desc": "Join all currently Selected Meshes into one",
"Optimization.remove_doubles_safely.label": "Remove Doubles Safely", "Optimization.remove_doubles_safely.label": "Remove Doubles Safely",
"Optimization.select_armature": "Please select an armature in Quick Access", "Optimization.remove_doubles_safely.desc": "Remove doubles on all meshes, making sure not to fuse things like mouths together",
"Optimization.no_armature_selected": "No armature selected",
"Optimization.no_meshes_found": "No meshes found for the selected armature",
"Optimization.materials_combined": "Combined {num_combined} materials",
"Optimization.meshes_joined": "Meshes joined successfully",
"Optimization.no_mesh_selected": "No mesh objects selected",
"Optimization.select_at_least_two_meshes": "Please select at least two mesh objects",
"Optimization.selected_meshes_joined": "Selected meshes joined successfully",
"Optimization.vertex_excluded": "Shapekey has a moved vertex at index \"{index}\", excluding from double merging!",
"Optimization.processing_shapekey": "Processing shapekey \"{shapekeyname}\" on mesh \"{mesh_name}\"",
"Optimization.processing_mesh_no_shapekeys": "Processing mesh with no shapekeys named \"{mesh_name}\"",
"Optimization.remove_doubles_completed": "Remove doubles operation completed",
"Tools.label": "Tools", "Tools.label": "Tools",
"Tools.tools_title.label": "Tools", "Tools.tools_title.label": "Tools",
"Tools.convert_to_resonite.label": "Convert to Resonite", "Tools.convert_to_resonite.label": "Convert to Resonite",
"Tools.convert_to_resonite.desc": "Converts bone names on a model to names compatible with Resonite", "Tools.convert_to_resonite.desc": "Converts bone names on a model to names compatible with Resonite",
"Tools.remove_doubles_safely.label": "Remove Doubles Safely",
"Tools.create_digitigrade_legs.label": "Create Digitigrade Legs", "Tools.create_digitigrade_legs.label": "Create Digitigrade Legs",
"Tools.select_armature": "Please select an armature in Quick Access", "Tools.create_digitigrade_legs.desc": "Create digitigrade legs from a selected bone chain",
"Tools.digitigrade_legs.error.bone_format": "Bone format incorrect! Please select a chain of 4 continuous bones!",
"Tools.digitigrade_legs.success": "Digitigrade legs created successfully",
"Tools.no_armature_selected": "No armature selected",
"Tools.bones_translated_with_fails": "Failed to translate {translate_bone_fails} bones to humanoid names. Adding \"<noik>\" to their names.",
"Tools.bones_translated_success": "Successfully translated all bones to humanoid names",
"TextureAtlas.label": "Texture Atlasing", "TextureAtlas.label": "Texture Atlasing",
"TextureAtlas.material_list_label": "Texture Atlas Material List Material", "TextureAtlas.material_list_label": "Texture Atlas Material List Material",
"TextureAtlas.reload_list": "Reload Texture Atlas Material List", "TextureAtlas.reload_list": "Reload Texture Atlas Material List",
"TextureAtlas.loaded_list": "Loaded Texture Atlas Material List", "TextureAtlas.loaded_list": "Loaded Texture Atlas Material List",
"TextureAtlas.atlas_materials": "Atlas Materials!", "TextureAtlas.atlas_materials": "Atlas Materials",
"TextureAtlas.atlas_materials_desc": "Atlas materials to optimize the model",
"TextureAtlas.atlas_completed": "Texture atlas creation completed",
"TextureAtlas.atlas_error": "An error occurred during texture atlas creation",
"VisemePanel.label": "Visemes", "VisemePanel.label": "Visemes",
"VisemePanel.select_mesh": "Select Mesh", "VisemePanel.select_mesh": "Select Mesh",
"VisemePanel.mouth_a.label": "Mouth A", "VisemePanel.mouth_a.label": "Mouth A",
@@ -60,6 +79,15 @@
"VisemePanel.error.selectMesh": "Select a mesh to create visemes", "VisemePanel.error.selectMesh": "Select a mesh to create visemes",
"VisemePanel.error.noArmature": "No armature selected", "VisemePanel.error.noArmature": "No armature selected",
"VisemePanel.info.selectMesh": "Select a mesh to create visemes", "VisemePanel.info.selectMesh": "Select a mesh to create visemes",
"VisemePanel.start_viseme_creation": "Starting viseme creation...",
"VisemePanel.selected_shapes": "Selected shapes: A={shape_a}, O={shape_o}, CH={shape_ch}",
"VisemePanel.creating_viseme": "Creating viseme: {viseme_name}",
"VisemePanel.sorting_shapekeys": "Sorting shape keys...",
"VisemePanel.viseme_creation_completed": "Viseme creation completed.",
"VisemePanel.creating_viseme_detail": "Creating viseme: {viseme_name}",
"VisemePanel.removing_existing_viseme": "Removing existing viseme: {viseme_name}",
"VisemePanel.mixing_shape": "Mixing shape: {shape_name} with value: {value}",
"VisemePanel.viseme_created_successfully": "Viseme {viseme_name} created successfully",
"AutoVisemeButton.label": "Create Visemes", "AutoVisemeButton.label": "Create Visemes",
"AutoVisemeButton.desc": "Create visemes automatically, based on shape keys", "AutoVisemeButton.desc": "Create visemes automatically, based on shape keys",
"AutoVisemeButton.error.noShapekeys": "No shape keys found", "AutoVisemeButton.error.noShapekeys": "No shape keys found",