mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-03 13:28:19 +00:00
run bbim_translations.py without bpy
This commit is contained in:
@@ -697,10 +697,8 @@ endif
|
|||||||
cp -r blenderbim/libs/desktop dist/blenderbim/libs/
|
cp -r blenderbim/libs/desktop dist/blenderbim/libs/
|
||||||
|
|
||||||
# generate translations module for BBIM build
|
# generate translations module for BBIM build
|
||||||
# note that bpy is typically available only for current Blender python version
|
|
||||||
pip install bpy
|
|
||||||
git clone https://github.com/IfcOpenShell/blenderbim-translations.git dist/working
|
git clone https://github.com/IfcOpenShell/blenderbim-translations.git dist/working
|
||||||
python blenderbim/scripts/bbim_translations.py -i "dist/working" -o "dist/blenderbim/translations.py"
|
python blenderbim/scripts/bbim_translations.py -i "dist/working" -o "dist/blenderbim"
|
||||||
rm -rf dist/working
|
rm -rf dist/working
|
||||||
|
|
||||||
# Remove dependencies also bundled with Blender
|
# Remove dependencies also bundled with Blender
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
import bpy
|
try:
|
||||||
import addon_utils
|
import bpy
|
||||||
|
import bl_i18n_utils
|
||||||
|
import addon_utils
|
||||||
|
BPY_IS_LOADED = True
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
BPY_IS_LOADED = False
|
||||||
|
|
||||||
import shutil
|
import shutil
|
||||||
import tempfile
|
import tempfile
|
||||||
import importlib
|
import importlib
|
||||||
import os
|
import os
|
||||||
import sys
|
|
||||||
import re
|
import re
|
||||||
import bl_i18n_utils
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@@ -22,7 +26,6 @@ bl_info = {
|
|||||||
"category": "System",
|
"category": "System",
|
||||||
}
|
}
|
||||||
|
|
||||||
context = bpy.context
|
|
||||||
# NOTE: list of available languages in Blender can be retrieved
|
# NOTE: list of available languages in Blender can be retrieved
|
||||||
# by the command below:
|
# by the command below:
|
||||||
# bpy.context.preferences.view.language = "test"
|
# bpy.context.preferences.view.language = "test"
|
||||||
@@ -36,7 +39,7 @@ def is_addon_loaded(addon_name) -> bool:
|
|||||||
|
|
||||||
|
|
||||||
def get_branches_directory():
|
def get_branches_directory():
|
||||||
return Path(context.preferences.filepaths.i18n_branches_directory)
|
return Path(bpy.context.preferences.filepaths.i18n_branches_directory)
|
||||||
|
|
||||||
|
|
||||||
def get_addon_directory() -> Path:
|
def get_addon_directory() -> Path:
|
||||||
@@ -326,8 +329,8 @@ def dump_addon_messages(module_name, do_checks, settings):
|
|||||||
|
|
||||||
return pot
|
return pot
|
||||||
|
|
||||||
|
if BPY_IS_LOADED:
|
||||||
class SetupTranslationUI(bpy.types.Operator):
|
class SetupTranslationUI(bpy.types.Operator):
|
||||||
bl_idname = "bim.setup_translation_ui"
|
bl_idname = "bim.setup_translation_ui"
|
||||||
bl_label = "Setup Translation UI"
|
bl_label = "Setup Translation UI"
|
||||||
bl_options = set()
|
bl_options = set()
|
||||||
@@ -415,7 +418,7 @@ class SetupTranslationUI(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class ReloadPyTranslations(bpy.types.Operator):
|
class ReloadPyTranslations(bpy.types.Operator):
|
||||||
bl_idname = "bim.reload_py_translations"
|
bl_idname = "bim.reload_py_translations"
|
||||||
bl_label = "Reload Py Translations"
|
bl_label = "Reload Py Translations"
|
||||||
bl_description = "Parse strings from Blender objects of the addon to `translations.py`"
|
bl_description = "Parse strings from Blender objects of the addon to `translations.py`"
|
||||||
@@ -441,7 +444,7 @@ class ReloadPyTranslations(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class ConvertTranslationsToPo(bpy.types.Operator):
|
class ConvertTranslationsToPo(bpy.types.Operator):
|
||||||
bl_idname = "bim.convert_translations_to_po"
|
bl_idname = "bim.convert_translations_to_po"
|
||||||
bl_label = "Convert Translations To .po"
|
bl_label = "Convert Translations To .po"
|
||||||
bl_description = (
|
bl_description = (
|
||||||
@@ -472,7 +475,7 @@ class ConvertTranslationsToPo(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class UpdateTranslationsFromPo(bpy.types.Operator):
|
class UpdateTranslationsFromPo(bpy.types.Operator):
|
||||||
bl_idname = "bim.update_translations_from_po"
|
bl_idname = "bim.update_translations_from_po"
|
||||||
bl_label = "Update Translations From .po"
|
bl_label = "Update Translations From .po"
|
||||||
bl_description = (
|
bl_description = (
|
||||||
@@ -508,7 +511,7 @@ class UpdateTranslationsFromPo(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class DisableEnableAddon(bpy.types.Operator):
|
class DisableEnableAddon(bpy.types.Operator):
|
||||||
bl_idname = "bim.disable_enable_addon"
|
bl_idname = "bim.disable_enable_addon"
|
||||||
bl_label = "Disable/Enable addon"
|
bl_label = "Disable/Enable addon"
|
||||||
bl_description = "Will enable addon if it's disabled, will disable it and restart Blender otherwise"
|
bl_description = "Will enable addon if it's disabled, will disable it and restart Blender otherwise"
|
||||||
@@ -532,7 +535,7 @@ class DisableEnableAddon(bpy.types.Operator):
|
|||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
class BBIM_PT_translations(bpy.types.Panel):
|
class BBIM_PT_translations(bpy.types.Panel):
|
||||||
bl_label = "BlenderBIM Translations"
|
bl_label = "BlenderBIM Translations"
|
||||||
bl_idname = "BBIM_PT_translations"
|
bl_idname = "BBIM_PT_translations"
|
||||||
bl_space_type = "PROPERTIES"
|
bl_space_type = "PROPERTIES"
|
||||||
@@ -568,22 +571,22 @@ class BBIM_PT_translations(bpy.types.Panel):
|
|||||||
layout.operator("bim.update_translations_from_po", icon="IMPORT")
|
layout.operator("bim.update_translations_from_po", icon="IMPORT")
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
ReloadPyTranslations,
|
ReloadPyTranslations,
|
||||||
ConvertTranslationsToPo,
|
ConvertTranslationsToPo,
|
||||||
UpdateTranslationsFromPo,
|
UpdateTranslationsFromPo,
|
||||||
SetupTranslationUI,
|
SetupTranslationUI,
|
||||||
DisableEnableAddon,
|
DisableEnableAddon,
|
||||||
BBIM_PT_translations,
|
BBIM_PT_translations,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def register():
|
def register():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.register_class(cls)
|
bpy.utils.register_class(cls)
|
||||||
|
|
||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
for cls in classes:
|
for cls in classes:
|
||||||
bpy.utils.unregister_class(cls)
|
bpy.utils.unregister_class(cls)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user