diff options
author | Bastien Montagne <bastien@blender.org> | 2020-12-04 17:08:11 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2020-12-04 17:14:16 +0300 |
commit | 06ae2e3a609fdc2081108e4163b7c62540618310 (patch) | |
tree | a36d2e62c7f20bd516b1ec5583ba0a1d9a7f47fb /release/scripts/modules/bl_i18n_utils/settings.py | |
parent | 7bd8b8cdacd2cd7036851a77b41c4c7767f09e5e (diff) |
i18n utils : Reduce dependency to Blender bpy API, step 2.
Remove some top imports of bpy, only import it in a few specific
functions that only make sense when used whithin Blender anyway.
Diffstat (limited to 'release/scripts/modules/bl_i18n_utils/settings.py')
-rw-r--r-- | release/scripts/modules/bl_i18n_utils/settings.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py index e304ef5ea17..cfa4fcac17f 100644 --- a/release/scripts/modules/bl_i18n_utils/settings.py +++ b/release/scripts/modules/bl_i18n_utils/settings.py @@ -30,7 +30,11 @@ import os import sys import types -import bpy +try: + import bpy +except ModuleNotFoundError: + print("Could not import bpy, some features are not available when not run from Blender.") + bpy = None ############################################################################### # MISC @@ -98,8 +102,10 @@ LANGUAGES = ( (47, "Slovak (SlovenĨina)", "sk_SK"), ) -# Default context, in py! -DEFAULT_CONTEXT = bpy.app.translations.contexts.default +# Default context, in py (keep in sync with `BLT_translation.h`)! +if bpy is not None: + assert(bpy.app.translations.contexts.default == "*") +DEFAULT_CONTEXT = "*" # Name of language file used by Blender to generate translations' menu. LANGUAGES_FILE = "languages" |