run bbim_translations.py without bpy

This commit is contained in:
Andrej730
2024-01-19 14:13:17 +05:00
parent b824ab4c4f
commit d1e2009d78
2 changed files with 244 additions and 243 deletions
+1 -3
View File
@@ -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
+8 -5
View File
@@ -1,12 +1,16 @@
try:
import bpy import bpy
import bl_i18n_utils
import addon_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,7 +329,7 @@ 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"