def load_slots(self): LoggedSlots.load_slots(self) # clobber enabled and translation using primary template if self.input_file != self._out_file(): parent_slots = TranslatorTemplate.get_slots() self.enabled = parent_slots.get('enabled', {}) self.source_trans = parent_slots.get('source_trans', {})
def load_slots(self): LoggedSlots.load_slots(self) # clobber enabled and translation using primary template if self.input_file != self._out_file(): parent_slots = TranslatorTemplate.get_slots() self.enabled = parent_slots.get('enabled',{}) self.source_trans = parent_slots.get('source_trans', {})
def __init__(self, domain = _domain, path = _i18n_path, locale = ''): self.strings = [] self.string_dict = {} self.sources = {} self.locale = locale self.input_file = TranslatorTemplate.outfile(locale) def _out_file(extension = None): d = dict(extension=extension) if extension is not None else {} return self.outfile(locale, path=path, domain=domain, **d) self._out_file = _out_file # create directory for translation if not os.path.exists(os.path.dirname(self._out_file('po'))): os.makedirs(os.path.dirname(self._out_file('po'))) LoggedSlots.__init__(self, self._out_file('data'), plural_names = ['singular', 'plural'], nplurals = 2, source_trans = {}, author = set([]), enabled = {}, num_completed = 0, num_total = 0, en_name = locale, name = locale, _is_enabled = False ) # no translation, use the infile to make one if not os.path.exists(self._out_file('po')): self.from_file(self.input_file) # translation exists: make sure infile is not newer else: i_stat = os.stat(self.input_file) o_stat = os.stat(self._out_file('po')) if i_stat.st_mtime > o_stat.st_mtime: self.from_file(self.input_file) self.load_specialty_strings() self.from_file(self._out_file('po'), merge=True) self.save() else: self.from_file(self._out_file('po')) self.load_specialty_strings()
def __init__(self, domain=_domain, path=_i18n_path, locale=''): self.strings = [] self.string_dict = {} self.sources = {} self.locale = locale self.input_file = TranslatorTemplate.outfile(locale) def _out_file(extension=None): d = dict(extension=extension) if extension is not None else {} return self.outfile(locale, path=path, domain=domain, **d) self._out_file = _out_file # create directory for translation if not os.path.exists(os.path.dirname(self._out_file('po'))): os.makedirs(os.path.dirname(self._out_file('po'))) LoggedSlots.__init__(self, self._out_file('data'), plural_names=['singular', 'plural'], nplurals=2, source_trans={}, author=set([]), enabled={}, num_completed=0, num_total=0, en_name=locale, name=locale, _is_enabled=False) # no translation, use the infile to make one if not os.path.exists(self._out_file('po')): self.from_file(self.input_file) # translation exists: make sure infile is not newer else: i_stat = os.stat(self.input_file) o_stat = os.stat(self._out_file('po')) if i_stat.st_mtime > o_stat.st_mtime: self.from_file(self.input_file) self.load_specialty_strings() self.from_file(self._out_file('po'), merge=True) self.save() else: self.from_file(self._out_file('po')) self.load_specialty_strings()
def get_slots(cls, locale = None): locale = locale or pylons.g.lang f = cls.outfile(locale, extension='data') return LoggedSlots._get_slots(f)
def get_slots(cls, locale=None): locale = locale or pylons.g.lang f = cls.outfile(locale, extension='data') return LoggedSlots._get_slots(f)
def get_slots(cls, locale = 'en'): f = cls.outfile(locale, extension='data') return LoggedSlots._get_slots(f)