import copy
import gettext
import logging
+import sys
try:
from pathlib import Path
except ImportError:
LOG = logging.getLogger(__name__)
-__version__ = '0.1.1'
+__version__ = '0.2.1'
__me__ = Path(__file__).resolve()
__module_dir__ = __me__.parent
__lib_dir__ = __module_dir__.parent
__base_dir__ = __lib_dir__.parent
-LOCALE_DIR = __base_dir__.joinpath('locale')
-if not LOCALE_DIR.is_dir():
- LOCALE_DIR = __module_dir__.joinpath('locale')
- if not LOCALE_DIR.is_dir():
- LOCALE_DIR = None
+LOCALE_DIR = __base_dir__ / 'locale'
+if LOCALE_DIR.is_dir():
+ # Not installed, in development workdir
+ LOCALE_DIR = str(LOCALE_DIR)
+else:
+ # Somehow installed
+ if sys.prefix == sys.base_prefix:
+ # installed as a package
+ LOCALE_DIR = sys.prefix + '/share/locale'
+ else:
+ # Obviously in a virtual environment
+ LOCALE_DIR = __lib_dir__ / 'usr' / 'local' / 'share' / 'locale'
+ if LOCALE_DIR.is_dir():
+ LOCALE_DIR = str(LOCALE_DIR.resolve())
+ else:
+ LOCALE_DIR = __module_dir__ / 'locale'
+ if LOCALE_DIR.is_dir():
+ LOCALE_DIR = str(LOCALE_DIR)
+ else:
+ LOCALE_DIR = sys.prefix + '/share/locale'
DEFAULT_LOCALE_DEF = 'en_US'
DEFAULT_LOCALE = babel.core.default_locale()