From fc69a22c627321be625bb7cbcf69602b3cf94f31 Mon Sep 17 00:00:00 2001 From: Yusarina Date: Thu, 25 Jul 2024 03:13:17 +0100 Subject: [PATCH] Function Translations Complete - Done Translations - Added self.reports for Atlas Materials. - Added self.reports for digitlgradelegs --- functions/atlas_materials.py | 6 +++-- functions/combine_materials.py | 6 ++--- functions/digitigrade_legs.py | 4 +++- functions/import_anything.py | 1 + functions/join_meshes.py | 13 +++++----- functions/remove_doubles_safely.py | 9 +++---- functions/resonite_functions.py | 6 ++--- functions/viseme.py | 1 - resources/translations/en_US.json | 38 ++++++++++++++++++++++++++---- 9 files changed, 58 insertions(+), 26 deletions(-) diff --git a/functions/atlas_materials.py b/functions/atlas_materials.py index c0e537a..d1001aa 100644 --- a/functions/atlas_materials.py +++ b/functions/atlas_materials.py @@ -119,8 +119,8 @@ def prep_images_in_scene(context: Context) -> list[MaterialImageList]: class Atlas_Materials(Operator): bl_idname = "avatar_toolkit.atlas_materials" - bl_label = "Atlas Materials" - bl_description = "Atlas materials to optimize the model" + bl_label = t("TextureAtlas.atlas_materials") + bl_description = t("TextureAtlas.atlas_materials_desc") bl_options = {'REGISTER', 'UNDO'} @classmethod @@ -270,8 +270,10 @@ class Atlas_Materials(Operator): mesh.materials.append(atlased_mat.material) + self.report({'INFO'}, t("TextureAtlas.atlas_completed")) return {"FINISHED"} except Exception as e: + self.report({'ERROR'}, t("TextureAtlas.atlas_error")) raise e return {"FINISHED"} diff --git a/functions/combine_materials.py b/functions/combine_materials.py index 473e881..43d4472 100644 --- a/functions/combine_materials.py +++ b/functions/combine_materials.py @@ -71,7 +71,7 @@ class CombineMaterials(Operator): def execute(self, context: Context) -> Set[str]: armature = get_selected_armature(context) if not armature: - self.report({'WARNING'}, "No armature selected") + self.report({'WARNING'}, t("Optimization.no_armature_selected")) return {'CANCELLED'} context.view_layer.objects.active = armature @@ -79,7 +79,7 @@ class CombineMaterials(Operator): meshes = get_all_meshes(context) if not meshes: - self.report({'WARNING'}, "No meshes found for the selected armature") + self.report({'WARNING'}, t("Optimization.no_meshes_found")) return {'CANCELLED'} self.consolidate_materials(meshes) @@ -111,7 +111,7 @@ class CombineMaterials(Operator): else: 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: for mat in bpy.data.materials: diff --git a/functions/digitigrade_legs.py b/functions/digitigrade_legs.py index 27ea3e5..0544e6a 100644 --- a/functions/digitigrade_legs.py +++ b/functions/digitigrade_legs.py @@ -32,7 +32,7 @@ class CreateDigitigradeLegs(bpy.types.Operator): digi2 = digi1.children[0] digi3 = digi2.children[0] 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'} digi4 = None try: @@ -114,4 +114,6 @@ class CreateDigitigradeLegs(bpy.types.Operator): digi1.name = re.compile(re.escape(""), re.IGNORECASE).sub("",digi1.name)+"" digi2.name = re.compile(re.escape(""), re.IGNORECASE).sub("",digi2.name)+"" #finally fully done! + + self.report({'INFO'}, t('Tools.digitigrade_legs.success')) return {'FINISHED'} \ No newline at end of file diff --git a/functions/import_anything.py b/functions/import_anything.py index f4a5921..58ed75e 100644 --- a/functions/import_anything.py +++ b/functions/import_anything.py @@ -77,6 +77,7 @@ class ImportAnyModel(Operator, ImportHelper): print("importer error was:") print(e) + self.report({'INFO'}, t('Quick_Access.import_success')) return {'FINISHED'} diff --git a/functions/join_meshes.py b/functions/join_meshes.py index 9fbe3a1..3310ae9 100644 --- a/functions/join_meshes.py +++ b/functions/join_meshes.py @@ -23,7 +23,7 @@ class JoinAllMeshes(Operator): def join_all_meshes(self, context: Context) -> None: if not select_current_armature(context): - self.report({'WARNING'}, "No armature selected") + self.report({'WARNING'}, t("Optimization.no_armature_selected")) return armature = get_selected_armature(context) @@ -41,9 +41,9 @@ class JoinAllMeshes(Operator): fix_uv_coordinates(context) bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') - self.report({'INFO'}, "Meshes joined successfully") + self.report({'INFO'}, t("Optimization.meshes_joined")) else: - self.report({'WARNING'}, "No mesh objects selected") + self.report({'WARNING'}, t("Optimization.no_mesh_selected")) 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'] 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 bpy.ops.object.mode_set(mode='OBJECT') @@ -82,7 +82,6 @@ class JoinSelectedMeshes(Operator): fix_uv_coordinates(context) bpy.ops.object.mode_set(mode='OBJECT') bpy.ops.object.select_all(action='DESELECT') - self.report({'INFO'}, "Selected meshes joined successfully") + self.report({'INFO'}, t("Optimization.selected_meshes_joined")) else: - self.report({'WARNING'}, "No mesh objects selected") - + self.report({'WARNING'}, t("Optimization.no_mesh_selected")) diff --git a/functions/remove_doubles_safely.py b/functions/remove_doubles_safely.py index 1631b68..9c2078c 100644 --- a/functions/remove_doubles_safely.py +++ b/functions/remove_doubles_safely.py @@ -6,7 +6,7 @@ from typing import List, Tuple, Optional, TypedDict from bpy.types import Material, Operator, Context, Object from ..core.register import register_wrap from ..core.common import get_selected_armature, is_valid_armature, select_current_armature, get_all_meshes - +from ..functions.translations import t class meshEntry(TypedDict): mesh: bpy.types.Object @@ -15,8 +15,8 @@ class meshEntry(TypedDict): @register_wrap class RemoveDoublesSafely(Operator): bl_idname = "avatar_toolkit.remove_doubles_safely" - bl_label = "Remove Doubles Safely" - bl_description = "Remove Doubles on all meshes, making sure to not fuse things like mouths together." + bl_label = t("Optimization.remove_doubles_safely.label") + bl_description = t("Optimization.remove_doubles_safely.desc") bl_options = {'REGISTER', 'UNDO'} objects_to_do: list[meshEntry] = [] merge_distance: bpy.props.FloatProperty(default=0.0001) @@ -28,7 +28,7 @@ class RemoveDoublesSafely(Operator): def execute(self, context: Context) -> set: if not select_current_armature(context): - self.report({'WARNING'}, "No armature selected") + self.report({'WARNING'}, t("Optimization.no_armature_selected")) return {'CANCELLED'} armature = get_selected_armature(context) @@ -117,6 +117,7 @@ class RemoveDoublesSafely(Operator): mesh["mesh"].select_set(False) else: + self.report({'INFO'}, t("Optimization.remove_doubles_completed")) return {'FINISHED'} return {'RUNNING_MODAL'} diff --git a/functions/resonite_functions.py b/functions/resonite_functions.py index 2b6a005..9d81d70 100644 --- a/functions/resonite_functions.py +++ b/functions/resonite_functions.py @@ -22,7 +22,7 @@ class ConvertToResonite(Operator): def execute(self, context: Context) -> set: armature = get_selected_armature(context) if not armature: - self.report({'WARNING'}, "No armature selected") + self.report({'WARNING'}, t("Tools.no_armature_selected")) return {'CANCELLED'} translate_bone_fails = 0 @@ -107,8 +107,8 @@ class ConvertToResonite(Operator): bpy.ops.object.mode_set(mode='OBJECT') if translate_bone_fails > 0: - self.report({'INFO'}, "Failed to translate {translate_bone_fails} bones to humanoid names. Adding \"\" 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: - self.report({'INFO'}, "Successfully translated all bones to humanoid names") + self.report({'INFO'}, t("Tools.bones_translated_success")) return {'FINISHED'} diff --git a/functions/viseme.py b/functions/viseme.py index 9ba8849..871ce73 100644 --- a/functions/viseme.py +++ b/functions/viseme.py @@ -63,7 +63,6 @@ class AutoVisemeButton(bpy.types.Operator): print("Sorting shape keys...") common.sort_shape_keys(mesh) - print("Viseme creation completed.") self.report({'INFO'}, t('AutoVisemeButton.success')) return {'FINISHED'} diff --git a/resources/translations/en_US.json b/resources/translations/en_US.json index 8319fe6..532cdd8 100644 --- a/resources/translations/en_US.json +++ b/resources/translations/en_US.json @@ -1,5 +1,5 @@ { - "authors": ["Avatar Toolkit Team"], + "authors": ["Avatar Toolkit Team"], "messages": { "Language.auto": "Automatic", "Language.en_US": "English", @@ -24,6 +24,7 @@ "Quick_Access.select_export_resonite.label": "Resonite", "Quick_Access.export_fbx.label": "Export 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.desc": "Export a GLB with all animations and materials. For animation data see:", "Optimization.label": "Optimization", @@ -35,19 +36,37 @@ "Optimization.join_selected_meshes.label": "Join Selected Meshes", "Optimization.join_selected_meshes.desc": "Join all currently Selected Meshes into one", "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.tools_title.label": "Tools", "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.remove_doubles_safely.label": "Remove Doubles Safely", "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 \"\" to their names.", + "Tools.bones_translated_success": "Successfully translated all bones to humanoid names", "TextureAtlas.label": "Texture Atlasing", "TextureAtlas.material_list_label": "Texture Atlas Material List Material", "TextureAtlas.reload_list": "Reload 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.select_mesh": "Select Mesh", "VisemePanel.mouth_a.label": "Mouth A", @@ -60,6 +79,15 @@ "VisemePanel.error.selectMesh": "Select a mesh to create visemes", "VisemePanel.error.noArmature": "No armature selected", "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.desc": "Create visemes automatically, based on shape keys", "AutoVisemeButton.error.noShapekeys": "No shape keys found",