diff --git a/__init__.py b/__init__.py index 4f93020..f49f0c7 100644 --- a/__init__.py +++ b/__init__.py @@ -1,5 +1,3 @@ - - if "bpy" not in locals(): import bpy from . import ui @@ -7,28 +5,40 @@ if "bpy" not in locals(): from . import functions from .core import register from .core.register import __bl_ordered_classes + from .core import properties + from .core import addon_preferences else: import importlib importlib.reload(ui) importlib.reload(core) importlib.reload(functions) - + importlib.reload(properties) + importlib.reload(addon_preferences) def register(): print("Registering Avatar Toolkit") + # Register the addon properties + properties.register() + + # Load the translations + functions.translations.load_translations() + # Order the classes before registration core.register.order_classes() + # Register the properties + core.register.register_properties() # Register the UI classes - - # Iterate over the classes to register and register them for cls in __bl_ordered_classes: print("registering" + str(cls)) bpy.utils.register_class(cls) + def unregister(): print("Unregistering Avatar Toolkit") # Unregister the UI classes - + # Iterate over the classes to unregister in reverse order and unregister them for cls in reversed(list(__bl_ordered_classes)): bpy.utils.unregister_class(cls) - print("unregistering" + str(cls)) + print("unregistering " + str(cls)) + core.register.unregister_properties() + properties.unregister() diff --git a/core/__init__.py b/core/__init__.py index d1f53d5..50c92e7 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1,7 +1,6 @@ # core/__init__.py from .register import register_wrap -from . import pmx #to reload all things in this directory and import them properly - @989onan if "bpy" not in locals(): diff --git a/core/addon_preferences.py b/core/addon_preferences.py new file mode 100644 index 0000000..7949f1d --- /dev/null +++ b/core/addon_preferences.py @@ -0,0 +1,43 @@ +import bpy +import os +import json +from bpy.types import AddonPreferences +from typing import Any, Dict + +# Get the directory of the current file +PREFERENCES_DIR = os.path.dirname(os.path.abspath(__file__)) +PREFERENCES_FILE = os.path.join(PREFERENCES_DIR, "preferences.json") + +def save_preference(key: str, value: Any) -> None: + """Save a single preference to the JSON file.""" + prefs = load_preferences() + prefs[key] = value + with open(PREFERENCES_FILE, 'w') as f: + json.dump(prefs, f, indent=4) + +def load_preferences() -> Dict[str, Any]: + """Load all preferences from the JSON file.""" + if os.path.exists(PREFERENCES_FILE): + with open(PREFERENCES_FILE, 'r') as f: + return json.load(f) + return {} + +def get_preference(key: str, default: Any = None) -> Any: + """Get a single preference from the JSON file.""" + prefs = load_preferences() + return prefs.get(key, default) + +class AvatarToolkitPreferences(AddonPreferences): + bl_idname = __package__.rsplit('.', 1)[0] + + def draw(self, context): + layout = self.layout + layout.label(text="Preferences are managed internally.") + # You can add more UI elements here if needed + +def get_addon_preferences(context): + return context.preferences.addons[AvatarToolkitPreferences.bl_idname].preferences + +# Initialize preferences if the file doesn't exist +if not os.path.exists(PREFERENCES_FILE): + save_preference("language", 0) # Set default language to 0 (auto) \ No newline at end of file diff --git a/core/export_resonite.py b/core/export_resonite.py index 5603773..4cb73fe 100644 --- a/core/export_resonite.py +++ b/core/export_resonite.py @@ -5,13 +5,14 @@ from .common import get_armature from bpy.types import Object, ShapeKey, Mesh, Context, Operator from functools import lru_cache from ..core.register import register_wrap +from ..functions.translations import t @register_wrap class ExportResonite(Operator): bl_idname = 'avatar_toolkit.export_resonite' - bl_label = "Export to Resonite" - bl_description = "Export a GLB with all animations and materials. For animation data see: " + bl_label = t("Export.resonite.label") + bl_description = t("Export.resonite.desc") bl_options = {'REGISTER', 'UNDO'} filepath: bpy.props.StringProperty() diff --git a/core/importer.py b/core/importer.py new file mode 100644 index 0000000..e29ca11 --- /dev/null +++ b/core/importer.py @@ -0,0 +1,17 @@ +import bpy + +# Importers which don't need much code should be added here, however if a importer needs alot of code +# Like the PMX and PMD importers, they should be added to their own files. + + +# FBX Importer settings borrowed form Cat's Blender Plugin +def import_fbx(filepath): + try: + bpy.ops.import_scene.fbx( + filepath=filepath, + automatic_bone_orientation=False, + use_prepost_rot=False, + use_anim=False + ) + except (TypeError, ValueError) as e: + print(f"Error importing FBX: {str(e)}") diff --git a/core/pmd/import_pmd.py b/core/pmd/import_pmd.py deleted file mode 100644 index d23f4a9..0000000 --- a/core/pmd/import_pmd.py +++ /dev/null @@ -1,224 +0,0 @@ -import bpy -import struct -import mathutils - -def read_pmd_header(file): - # Read PMD header information - magic = file.read(3) - if magic != b'Pmd': - raise ValueError("Invalid PMD file") - - version = struct.unpack(' bool: return tex1.image == tex2.image and tex1.extension == tex2.extension @@ -58,8 +59,8 @@ def report_consolidated(self: Operator, num_combined: int) -> None: @register_wrap class CombineMaterials(Operator): bl_idname = "avatar_toolkit.combine_materials" - bl_label = "Combine Materials" - bl_description = "Combine similar materials to optimize the model" + bl_label = t("Optimization.combine_materials.label") + bl_description = t("Optimization.combine_materials.desc") bl_options = {'REGISTER', 'UNDO'} @classmethod diff --git a/functions/join_meshes.py b/functions/join_meshes.py index b2edfef..195870e 100644 --- a/functions/join_meshes.py +++ b/functions/join_meshes.py @@ -3,12 +3,13 @@ from typing import List, Optional from bpy.types import Operator, Context, Object from ..core.register import register_wrap from ..core.common import fix_uv_coordinates +from ..functions.translations import t @register_wrap class JoinAllMeshes(Operator): bl_idname = "avatar_toolkit.join_all_meshes" - bl_label = "Join All Meshes" - bl_description = "Join all meshes in the scene" + bl_label = t("Optimization.join_all_meshes.label") + bl_description = t("Optimization.join_all_meshes.desc") bl_options = {'REGISTER', 'UNDO'} @classmethod @@ -45,8 +46,8 @@ class JoinAllMeshes(Operator): @register_wrap class JoinSelectedMeshes(Operator): bl_idname = "avatar_toolkit.join_selected_meshes" - bl_label = "Join Selected Meshes" - bl_description = "Join selected meshes" + bl_label = t("Optimization.join_selected_meshes.label") + bl_description = t("Optimization.join_selected_meshes.desc") bl_options = {'REGISTER', 'UNDO'} @classmethod diff --git a/functions/resonite_functions.py b/functions/resonite_functions.py index adaeead..74a80be 100644 --- a/functions/resonite_functions.py +++ b/functions/resonite_functions.py @@ -5,12 +5,13 @@ import re from bpy.types import Operator, Context, Object from ..core.dictionaries import bone_names from ..core.common import get_armature, simplify_bonename +from ..functions.translations import t @register_wrap class ConvertToResonite(Operator): bl_idname = 'avatar_toolkit.convert_to_resonite' - bl_label = "Convert to Resonite" #t('Tools.convert_to_resonite.label') - bl_description = "Converts bone names on a model to names compatable with Resonite" #t('Tools.convert_to_resonite.desc') + bl_label = t('Tools.convert_to_resonite.label') + bl_description = t('Tools.convert_to_resonite.desc') bl_options = {'REGISTER', 'UNDO'} @classmethod diff --git a/functions/translations.py b/functions/translations.py new file mode 100644 index 0000000..9e2a742 --- /dev/null +++ b/functions/translations.py @@ -0,0 +1,97 @@ +import os +import json +import bpy +from bpy.app.translations import locale +from typing import Dict, List, Tuple +from ..core.addon_preferences import save_preference, get_preference + +# Use __file__ to get the current file's directory +current_dir = os.path.dirname(os.path.abspath(__file__)) +main_dir = os.path.dirname(current_dir) +resources_dir = os.path.join(main_dir, "resources") +translations_dir = os.path.join(resources_dir, "translations") + +dictionary: Dict[str, str] = dict() +languages: List[str] = [] +verbose: bool = True + +def load_translations() -> bool: + global dictionary, languages + + old_dictionary = dictionary.copy() + + dictionary = dict() + languages = ["auto"] + + # Populate languages list + for i in os.listdir(translations_dir): + lang = i.split(".")[0] + if lang != "auto": + languages.append(lang) + + language_index = get_preference("language", 0) + print(f"Loading translations for language index: {language_index}") # Debug print + + if language_index == 0: # "auto" + language = bpy.context.preferences.view.language + else: + try: + language = languages[language_index] + except IndexError: + language = bpy.context.preferences.view.language + + print(f"Selected language: {language}") # Debug print + + translation_file: str = os.path.join(translations_dir, language + ".json") + if os.path.exists(translation_file): + with open(translation_file, 'r', encoding='utf-8') as file: + dictionary = json.load(file)["messages"] + print(f"Loaded translations: {dictionary}") # Debug print + else: + custom_language: str = language.split("_")[0] + custom_translation_file: str = os.path.join(translations_dir, custom_language + ".json") + if os.path.exists(custom_translation_file): + with open(custom_translation_file, 'r', encoding='utf-8') as file: + dictionary = json.load(file)["messages"] + print(f"Loaded custom translations: {dictionary}") # Debug print + else: + print(f"Translation file not found for language: {language}") + default_file: str = os.path.join(translations_dir, "en_US.json") + if os.path.exists(default_file): + with open(default_file, 'r', encoding='utf-8') as file: + dictionary = json.load(file)["messages"] + print(f"Loaded default translations: {dictionary}") # Debug print + else: + print("Default translation file 'en_US.json' not found.") + + return dictionary != old_dictionary + +def t(phrase: str, default: str = None) -> str: + output: str = dictionary.get(phrase) + if output is None: + if verbose: + print(f'Warning: Unknown phrase: {phrase}') + return default if default is not None else phrase + print(f"Translating '{phrase}' to '{output}'") # Debug print + return output + +def get_language_display_name(lang: str) -> str: + if lang == "auto": + return t("Language.auto", "Automatic") + return t(f"Language.{lang}", lang) + +def get_languages_list(self, context) -> List[Tuple[str, str, str]]: + return [(str(i), get_language_display_name(lang), f"Use {lang} language") for i, lang in enumerate(languages)] + +def update_language(self, context): + print(f"Updating language to: {self.avatar_toolkit_language}") # Debug print + save_preference("language", int(self.avatar_toolkit_language)) + load_translations() + # Set a flag to indicate that a language change has occurred + context.scene.avatar_toolkit_language_changed = True + # Show popup after language change + bpy.ops.avatar_toolkit.translation_restart_popup('INVOKE_DEFAULT') + +# Initial load of translations +print("Performing initial load of translations") # Debug print +load_translations() diff --git a/resources/translations/en_US.json b/resources/translations/en_US.json new file mode 100644 index 0000000..e5a05f3 --- /dev/null +++ b/resources/translations/en_US.json @@ -0,0 +1,42 @@ +{ + "authors": ["Avatar Toolkit Team"], + "messages": { + "Language.auto": "Automatic", + "Language.en_US": "English", + "Language.ja_JP": "日本語", + "Quick_Access.label": "Quick Access", + "Quick_Access.import_export.label": "Import/Export", + "Quick_Access.options": "Quick Access Options", + "Quick_Access.import_menu.label": "Import Menu", + "Quick_Access.import": "Import", + "Quick_Access.export": "Export", + "Quick_Access.import_pmx": "Import PMX", + "Quick_Access.import_pmx.desc": "Import MMD PMX Model", + "Quick_Access.import_pmd": "Import PMD", + "Quick_Access.import_pmd.desc": "Import MMD PMD Model", + "Quick_Access.export_menu.label": "Export Menu", + "Quick_Access.select_export.label": "Select Export Method", + "Quick_Access.select_export_resonite.label": "Resonite", + "Export.resonite.label": "Export to Resonite", + "Export.resonite.desc": "Export a GLB with all animations and materials. For animation data see:", + "Optimization.label": "Optimization", + "Optimization.options.label": "Optimization Options", + "Optimization.combine_materials.label": "Combine Materials", + "Optimization.combine_materials.desc": "Combine similar materials to optimize the model", + "Optimization.join_all_meshes.label": "Join All Meshes", + "Optimization.join_all_meshes.desc": "Join all meshes into one", + "Optimization.join_selected_meshes.label": "Join Selected Mehses", + "Optimization.join_selected_meshes.desc": "Join all currntly Selected Mehses into one", + "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 compatable with Resonite", + "Settings.label": "Settings", + "Settings.language.label": "Language", + "Settings.language.desc": "Select the language for the addon's UI", + "Settings.translation_restart_popup.label": "Translation Update", + "Settings.translation_restart_popup.description": "Information about translation updates", + "Settings.translation_restart_popup.message1": "Some translations may not apply", + "Settings.translation_restart_popup.message2": "until you restart Blender." + } + } + \ No newline at end of file diff --git a/resources/translations/ja_JP.json b/resources/translations/ja_JP.json new file mode 100644 index 0000000..8e2c537 --- /dev/null +++ b/resources/translations/ja_JP.json @@ -0,0 +1,41 @@ +{ + "authors": ["Avatar Toolkit Team"], + "messages": { + "Language.auto": "Automatic", + "Language.en_US": "English", + "Language.ja_JP": "日本語", + "Quick_Access.label": "クイックアクセス", + "Quick_Access.import_export.label": "インポート/エクスポート", + "Quick_Access.options": "クイックアクセスオプション", + "Quick_Access.import_menu.label": "インポートメニュー", + "Quick_Access.import": "インポート", + "Quick_Access.export": "エクスポート", + "Quick_Access.import_pmx": "PMXインポート", + "Quick_Access.import_pmx.desc": "MMD PMXモデルをインポート", + "Quick_Access.import_pmd": "PMDインポート", + "Quick_Access.import_pmd.desc": "MMD PMDモデルをインポート", + "Quick_Access.export_menu.label": "エクスポートメニュー", + "Quick_Access.select_export.label": "エクスポート方法を選択", + "Quick_Access.select_export_resonite.label": "Resonite", + "Export.resonite.label": "Resoniteにエクスポート", + "Export.resonite.desc": "すべてのアニメーションとマテリアルを含むGLBをエクスポートします。アニメーションデータについては以下を参照してください:", + "Optimization.label": "最適化", + "Optimization.options.label": "最適化オプション", + "Optimization.combine_materials.label": "マテリアルを結合", + "Optimization.combine_materials.desc": "類似したマテリアルを結合してモデルを最適化します", + "Optimization.join_all_meshes.label": "すべてのメッシュを結合", + "Optimization.join_all_meshes.desc": "すべてのメッシュを1つに結合します", + "Optimization.join_selected_meshes.label": "選択したメッシュを結合", + "Optimization.join_selected_meshes.desc": "現在選択されているすべてのメッシュを1つに結合します", + "Tools.tools_title.label": "ツール", + "Tools.convert_to_resonite.label": "Resoniteに変換", + "Tools.convert_to_resonite.desc": "モデルのボーン名をResoniteと互換性のある名前に変換します", + "Settings.label": "設定", + "Settings.language.label": "言語", + "Settings.language.desc": "アドオンのUI言語を選択してください", + "Settings.translation_restart_popup.label": "翻訳の更新", + "Settings.translation_restart_popup.description": "翻訳の更新に関する情報", + "Settings.translation_restart_popup.message1": "一部の翻訳は適用されない場合があります", + "Settings.translation_restart_popup.message2": "Blenderを再起動するまで。" + } +} diff --git a/ui/__init__.py b/ui/__init__.py index cc0041c..7db3379 100644 --- a/ui/__init__.py +++ b/ui/__init__.py @@ -13,7 +13,3 @@ else: for module_name in [ basename(f)[:-3] for f in modules if isfile(f) and not f.endswith('__init__.py')]: print("reloading " +module_name) exec("importlib.reload("+module_name+")") - - - - diff --git a/ui/optimization.py b/ui/optimization.py index 0de9bae..bcad49c 100644 --- a/ui/optimization.py +++ b/ui/optimization.py @@ -1,10 +1,11 @@ import bpy from ..core.register import register_wrap from .panel import AvatarToolkitPanel +from ..functions.translations import t @register_wrap class AvatarToolkitOptimizationPanel(bpy.types.Panel): - bl_label = "Optimization" + bl_label = t("Optimization.label") bl_idname = "OBJECT_PT_avatar_toolkit_optimization" bl_space_type = 'VIEW_3D' bl_region_type = 'UI' @@ -13,18 +14,19 @@ class AvatarToolkitOptimizationPanel(bpy.types.Panel): def draw(self, context): layout = self.layout - layout.label(text="Optimization Options") + layout.label(text=t("Optimization.options.label")) row = layout.row() row.scale_y = 1.2 - row.operator("avatar_toolkit.combine_materials", text="Combine Materials") + row.operator("avatar_toolkit.combine_materials", text=t("Optimization.combine_materials.label")) + layout.separator(factor=0.5) row = layout.row(align=True) row.scale_y = 1.2 - row.operator("avatar_toolkit.join_all_meshes", text="Join All Meshes") - row.operator("avatar_toolkit.join_selected_meshes", text="Join Selected Meshes") + row.operator("avatar_toolkit.join_all_meshes", text=t("Optimization.join_all_meshes.label")) + row.operator("avatar_toolkit.join_selected_meshes", text=t("Optimization.join_selected_meshes.label")) row.operator("avatar_toolkit.remove_doubles_safely", text="Remove Doubles Safely") # Add optimization options here diff --git a/ui/panel.py b/ui/panel.py index a987a28..29829de 100644 --- a/ui/panel.py +++ b/ui/panel.py @@ -1,5 +1,6 @@ import bpy from ..core.register import register_wrap +from ..functions.translations import t @register_wrap class AvatarToolkitPanel(bpy.types.Panel): diff --git a/ui/quick_access.py b/ui/quick_access.py index 1d93c25..81b9bee 100644 --- a/ui/quick_access.py +++ b/ui/quick_access.py @@ -2,13 +2,15 @@ import bpy from ..core.register import register_wrap from .panel import AvatarToolkitPanel from bpy.types import Context +from ..functions.translations import t from ..core.import_pmx import import_pmx from ..core.import_pmd import import_pmd +from ..core.importer import import_fbx @register_wrap class AvatarToolkitQuickAccessPanel(bpy.types.Panel): - bl_label = "Quick Access" + bl_label = t("Quick_Access.label") bl_idname = "OBJECT_PT_avatar_toolkit_quick_access" bl_space_type = 'VIEW_3D' bl_region_type = 'UI' @@ -17,22 +19,23 @@ class AvatarToolkitQuickAccessPanel(bpy.types.Panel): def draw(self, context: Context): layout = self.layout - layout.label(text="Quick Access Options") - + layout.label(text=t("Quick_Access.options")) + row = layout.row() - row.label(text="Import/Export", icon='IMPORT') + row.label(text=t("Quick_Access.import_export.label"), icon='IMPORT') layout.separator(factor=0.5) row = layout.row(align=True) row.scale_y = 1.5 - row.operator("avatar_toolkit.import_menu", text="Import") - row.operator("avatar_toolkit.export_menu", text="Export") + row.operator("avatar_toolkit.import_menu", text=t("Quick_Access.import")) + row.operator("avatar_toolkit.export_menu", text=t("Quick_Access.export")) @register_wrap class AVATAR_TOOLKIT_OT_import_menu(bpy.types.Operator): bl_idname = "avatar_toolkit.import_menu" - bl_label = "Import Menu" + bl_label = t("Quick_Access.import_menu.label") + bl_description = t("Quick_Access.import_menu.desc") def execute(self, context: Context): return {'FINISHED'} @@ -44,13 +47,19 @@ class AVATAR_TOOLKIT_OT_import_menu(bpy.types.Operator): def draw(self, context: Context): layout = self.layout layout.label(text="Select Import Method") - layout.operator("avatar_toolkit.import_pmx", text="Import PMX") - layout.operator("avatar_toolkit.import_pmd", text="Import PMD") + layout.operator("avatar_toolkit.import_pmx", text=t("Quick_Access.import_pmx")) + layout.operator("avatar_toolkit.import_pmd", text=t("Quick_Access.import_pmd")) + layout.operator("avatar_toolkit.import_fbx", text="Import FBX") @register_wrap class AVATAR_TOOLKIT_OT_export_menu(bpy.types.Operator): bl_idname = "avatar_toolkit.export_menu" - bl_label = "Export Menu" + bl_label = t("Quick_Access.export_menu.label") + bl_description = t("Quick_Access.import_pmx.desc") + + @classmethod + def poll(cls, context): + return any(obj.type == 'MESH' for obj in context.scene.objects) def execute(self, context: Context): return {'FINISHED'} @@ -61,13 +70,14 @@ class AVATAR_TOOLKIT_OT_export_menu(bpy.types.Operator): def draw(self, context: Context): layout = self.layout - layout.label(text="Select Export Method") - layout.operator("avatar_toolkit.export_resonite", text="Export Resonite") + layout.label(text=t("Quick_Access.select_export.label")) + layout.operator("avatar_toolkit.export_resonite", text=t("Quick_Access.select_export_resonite.label")) + layout.operator("avatar_toolkit.export_fbx", text="Export FBX") @register_wrap class AVATAR_TOOLKIT_OT_import_pmx(bpy.types.Operator): bl_idname = "avatar_toolkit.import_pmx" - bl_label = "Import PMX" + bl_label = t("Quick_Access.import_pmx") filepath: bpy.props.StringProperty(subtype="FILE_PATH") @@ -82,7 +92,7 @@ class AVATAR_TOOLKIT_OT_import_pmx(bpy.types.Operator): @register_wrap class AVATAR_TOOLKIT_OT_import_pmd(bpy.types.Operator): bl_idname = "avatar_toolkit.import_pmd" - bl_label = "Import PMD" + bl_label = t("Quick_Access.import_pmd") filepath: bpy.props.StringProperty(subtype="FILE_PATH") @@ -93,3 +103,31 @@ class AVATAR_TOOLKIT_OT_import_pmd(bpy.types.Operator): def invoke(self, context: Context, event): context.window_manager.fileselect_add(self) return {'RUNNING_MODAL'} + +@register_wrap +class AVATAR_TOOLKIT_OT_import_fbx(bpy.types.Operator): + bl_idname = "avatar_toolkit.import_fbx" + bl_label = "Import FBX" + + filepath: bpy.props.StringProperty(subtype="FILE_PATH") + + def execute(self, context): + import_fbx(self.filepath) + return {'FINISHED'} + + def invoke(self, context, event): + context.window_manager.fileselect_add(self) + return {'RUNNING_MODAL'} + +@register_wrap +class AVATAR_TOOLKIT_OT_export_fbx(bpy.types.Operator): + bl_idname = 'avatar_toolkit.export_fbx' + bl_label = "Export FBX" + bl_description = "Export the model as FBX" + bl_options = {'REGISTER', 'UNDO', 'INTERNAL'} + + def execute(self, context): + bpy.ops.export_scene.fbx('INVOKE_DEFAULT') + return {'FINISHED'} + + diff --git a/ui/settings.py b/ui/settings.py new file mode 100644 index 0000000..9714da6 --- /dev/null +++ b/ui/settings.py @@ -0,0 +1,39 @@ +import bpy +from ..core.register import register_wrap +from .panel import AvatarToolkitPanel +from ..functions.translations import t + +@register_wrap +class AvatarToolkitSettingsPanel(bpy.types.Panel): + bl_label = t("Settings.label") + bl_idname = "OBJECT_PT_avatar_toolkit_settings" + bl_space_type = 'VIEW_3D' + bl_region_type = 'UI' + bl_category = "Avatar Toolkit" + bl_parent_id = "OBJECT_PT_avatar_toolkit" + + def draw(self, context): + layout = self.layout + layout.prop(context.scene, "avatar_toolkit_language", text=t("Settings.language.label")) + +@register_wrap +class AVATAR_TOOLKIT_OT_translation_restart_popup(bpy.types.Operator): + bl_idname = "avatar_toolkit.translation_restart_popup" + bl_label = t("Settings.translation_restart_popup.label") + bl_description = t("Settings.translation_restart_popup.description") + bl_options = {'INTERNAL'} + + def execute(self, context): + if context.scene.avatar_toolkit_language_changed: + # Reload the addon after the popup is closed + bpy.ops.script.reload() + context.scene.avatar_toolkit_language_changed = False + return {'FINISHED'} + + def invoke(self, context, event): + return context.window_manager.invoke_props_dialog(self, width=300) + + def draw(self, context): + layout = self.layout + layout.label(text=t("Settings.translation_restart_popup.message1")) + layout.label(text=t("Settings.translation_restart_popup.message2")) diff --git a/ui/tools.py b/ui/tools.py index 2c2ea05..d25a4be 100644 --- a/ui/tools.py +++ b/ui/tools.py @@ -2,6 +2,7 @@ import bpy from ..core.register import register_wrap from .panel import AvatarToolkitPanel from bpy.types import Context +from ..functions.translations import t @register_wrap class AvatarToolkitToolsPanel(bpy.types.Panel): @@ -14,11 +15,11 @@ class AvatarToolkitToolsPanel(bpy.types.Panel): def draw(self, context: Context): layout = self.layout - layout.label(text="Tools") + layout.label(text=t("Tools.tools_title.label")) layout.separator(factor=0.5) row = layout.row(align=True) row.scale_y = 1.5 - row.operator("avatar_toolkit.convert_to_resonite", text="Translate to Resonite") + row.operator("avatar_toolkit.convert_to_resonite", text=t("Tools.convert_to_resonite.label")) row = layout.row(align=True) - row.operator("avatar_toolkit.remove_doubles_safely", text="Remove Doubles Safely") \ No newline at end of file + row.operator("avatar_toolkit.remove_doubles_safely", text="Remove Doubles Safely")