def initialize2(context): # allow for disabling PTS entirely by setting an environment variable. if bool(os.getenv('DISABLE_PTS')): log('Disabled by environment variable "DISABLE_PTS".', logging.WARNING) return cp = getattr(getattr(context, '_ProductContext__app', None), 'Control_Panel', None) # argh if cp is not None and cp_id in cp.objectIds(): cp_ts = getattr(cp, cp_id, None) # Clean up ourselves if cp_ts is not None: cp._delObject(cp_id) _remove_mo_cache(CACHE_PATH) # load translation files from all packages and products loaded = {} import Products packages = get_registered_packages() for package in packages: name = package.__name__ path = package.__path__[0] loaded[name] = True i18n_dir = os.path.join(path, 'i18n') if isdir(i18n_dir): _load_i18n_dir(i18n_dir) for product in get_products(): name = product[1] if name in IGNORED: continue basepath = product[3] fullname = 'Products.' + name # Avoid loading products registered as packages twice if loaded.get(fullname): continue loaded[fullname] = True i18n_dir = os.path.join(basepath, name, 'i18n') if isdir(i18n_dir): _load_i18n_dir(i18n_dir)
def purgeCache(self): """Purge the cache and remove all compiled mo files.""" return _remove_mo_cache(CACHE_PATH)