139 import os |
139 import os |
140 import logging |
140 import logging |
141 from smtplib import SMTP |
141 from smtplib import SMTP |
142 from threading import Lock |
142 from threading import Lock |
143 from os.path import (exists, join, expanduser, abspath, normpath, |
143 from os.path import (exists, join, expanduser, abspath, normpath, |
144 basename, isdir, dirname) |
144 basename, isdir, dirname, splitext) |
145 from warnings import warn |
145 from warnings import warn |
146 from logilab.common.decorators import cached, classproperty |
146 from logilab.common.decorators import cached, classproperty |
147 from logilab.common.deprecation import deprecated |
147 from logilab.common.deprecation import deprecated |
148 from logilab.common.logging_ext import set_log_methods, init_log |
148 from logilab.common.logging_ext import set_log_methods, init_log |
149 from logilab.common.configuration import (Configuration, Method, |
149 from logilab.common.configuration import (Configuration, Method, |
397 if CWDEV: |
397 if CWDEV: |
398 return join(CW_SOFTWARE_ROOT, 'i18n') |
398 return join(CW_SOFTWARE_ROOT, 'i18n') |
399 return join(cls.shared_dir(), 'i18n') |
399 return join(cls.shared_dir(), 'i18n') |
400 |
400 |
401 @classmethod |
401 @classmethod |
|
402 def cw_languages(cls): |
|
403 for fname in os.listdir(join(cls.i18n_lib_dir())): |
|
404 if fname.endswith('.po'): |
|
405 yield splitext(fname)[0] |
|
406 |
|
407 |
|
408 @classmethod |
402 def available_cubes(cls): |
409 def available_cubes(cls): |
403 import re |
410 import re |
404 cubes = set() |
411 cubes = set() |
405 for directory in cls.cubes_search_path(): |
412 for directory in cls.cubes_search_path(): |
406 if not exists(directory): |
413 if not exists(directory): |
945 # instance methods used to get instance specific resources ############# |
952 # instance methods used to get instance specific resources ############# |
946 |
953 |
947 def __init__(self, appid, debugmode=False): |
954 def __init__(self, appid, debugmode=False): |
948 self.appid = appid |
955 self.appid = appid |
949 super(CubicWebConfiguration, self).__init__(debugmode) |
956 super(CubicWebConfiguration, self).__init__(debugmode) |
|
957 fake_gettext = (unicode, lambda ctx, msgid: unicode(msgid)) |
|
958 for lang in self.available_languages(): |
|
959 self.translations[lang] = fake_gettext |
950 self._cubes = None |
960 self._cubes = None |
951 self.load_file_configuration(self.main_config_file()) |
961 self.load_file_configuration(self.main_config_file()) |
952 |
962 |
953 def adjust_sys_path(self): |
963 def adjust_sys_path(self): |
954 super(CubicWebConfiguration, self).adjust_sys_path() |
964 super(CubicWebConfiguration, self).adjust_sys_path() |