diff --git a/io_scene_psk_psa/i18n.py b/io_scene_psk_psa/i18n.py index c1a1c45..7993e96 100644 --- a/io_scene_psk_psa/i18n.py +++ b/io_scene_psk_psa/i18n.py @@ -15,8 +15,13 @@ langs = { ('*', 'Select a PSA file'): 'PSAファイルを選択', ('*', 'Case Insensitive'): '大文字小文字を区別しない', ('*', 'All bones will be exported'): 'すべてのボーンがエクスポートされます', - ('*', 'Only bones belonging to the selected bone groups and their ancestors will be exported'): + ('*', 'Only bones belonging to the selected bone collections and their ancestors will be exported'): '選択したボーングループとその祖先に属するボーンのみがエクスポートされます', ('*', 'Raw Mesh Data'): '生のメッシュデータ', + ('*', 'At least one bone must be marked for export'): '少なくとも 1 つのボーンをエクスポート用にマークする必要があります', + ('*', 'Number of wedges ({wedge_count}) exceeds limit of {max_wedge_count}'): 'ウェッジの数({wedge_count})が{max_wedge_count}の制限を超えています', + ('*', 'Numbers of vertices ({point_count}) exceeds limit of {max_point_count}'): '頂点の数({point_count})が{max_point_count}の制限を超えています', + ('*', 'Number of materials ({material_count}) exceeds limit of {max_material_count}'): 'マテリアルの数({material_count})が{max_material_count}の制限を超えています', + ('*', 'Number of bones ({bone_count}) exceeds limit of {max_bone_count}'): 'ボーンの数({bone_count})が{max_bone_count}の制限を超えています', } } diff --git a/io_scene_psk_psa/psk/export/operators.py b/io_scene_psk_psa/psk/export/operators.py index 80e097f..814ed86 100644 --- a/io_scene_psk_psa/psk/export/operators.py +++ b/io_scene_psk_psa/psk/export/operators.py @@ -26,7 +26,9 @@ def populate_material_list(mesh_objects, material_list): material = material_slot.material # TODO: put this in the poll arg? if material is None: - raise RuntimeError('Material slot cannot be empty (index ' + str(i) + ')') + message = 'Material slot cannot be empty (index {index})' + message = bpy.app.translations.pgettext_iface(message.format(index=i)) + raise RuntimeError(message) if material.name not in material_names: material_names.append(material.name) diff --git a/io_scene_psk_psa/psk/writer.py b/io_scene_psk_psa/psk/writer.py index eec3234..dd528cd 100644 --- a/io_scene_psk_psa/psk/writer.py +++ b/io_scene_psk_psa/psk/writer.py @@ -1,6 +1,8 @@ from ctypes import Structure, sizeof from typing import Type +import bpy.app.translations + from .data import Psk from ..data import Section, Vector3 @@ -24,15 +26,20 @@ def _write_section(fp, name: bytes, data_type: Type[Structure] = None, data: lis def write_psk(psk: Psk, path: str): if len(psk.wedges) > MAX_WEDGE_COUNT: - raise RuntimeError(f'Number of wedges ({len(psk.wedges)}) exceeds limit of {MAX_WEDGE_COUNT}') + message = bpy.app.translations.pgettext_iface('Number of wedges ({wedge_count}) exceeds limit of {MAX_WEDGE_COUNT}') + raise RuntimeError(message.format(wedge_count=len(psk.wedges), MAX_WEDGE_COUNT=MAX_WEDGE_COUNT)) if len(psk.points) > MAX_POINT_COUNT: - raise RuntimeError(f'Numbers of vertices ({len(psk.points)}) exceeds limit of {MAX_POINT_COUNT}') + message = bpy.app.translations.pgettext_iface('Numbers of vertices ({point_count}) exceeds limit of {MAX_POINT_COUNT}') + raise RuntimeError(message.format(point_count=len(psk.points), MAX_POINT_COUNT=MAX_POINT_COUNT)) if len(psk.materials) > MAX_MATERIAL_COUNT: - raise RuntimeError(f'Number of materials ({len(psk.materials)}) exceeds limit of {MAX_MATERIAL_COUNT}') + message = bpy.app.translations.pgettext_iface('Number of materials ({material_count}) exceeds limit of {MAX_MATERIAL_COUNT}') + raise RuntimeError(message.format(material_count=len(psk.materials), MAX_MATERIAL_COUNT=MAX_MATERIAL_COUNT)) if len(psk.bones) > MAX_BONE_COUNT: - raise RuntimeError(f'Number of bones ({len(psk.bones)}) exceeds limit of {MAX_BONE_COUNT}') + message = bpy.app.translations.pgettext_iface('Number of bones ({bone_count}) exceeds limit of {MAX_BONE_COUNT}') + raise RuntimeError(message.format(bone_count=len(psk.bones), MAX_BONE_COUNT=MAX_BONE_COUNT)) elif len(psk.bones) == 0: - raise RuntimeError(f'At least one bone must be marked for export') + message = bpy.app.translations.pgettext_iface('At least one bone must be marked for export') + raise RuntimeError(message) with open(path, 'wb') as fp: _write_section(fp, b'ACTRHEAD')