Ejemplo n.º 1
0
    def getDefaultFormat(self):
        """Overridable: return default file format to use for the export."""
        if not IHasTranslationTemplates.providedBy(self.context):
            raise NotImplementedError(
                'Subclass not implementing `IHasTranslationsTemplates` '
                'interface.  Either override getDefaultFormat implementation '
                'or implement `IHasTranslationsTemplates`.')

        templates = self.context.getCurrentTranslationTemplates()
        if not bool(templates.any()):
            return None
        formats = self.context.getTranslationTemplateFormats()
        format = formats[0]
        if len(formats) > 1:
            self.request.response.addInfoNotification(
                "This package has templates with different native "
                "file formats.  If you proceed, all translations will be "
                "exported in the single format you specify.")
        return format
Ejemplo n.º 2
0
    def getDefaultFormat(self):
        """Overridable: return default file format to use for the export."""
        if not IHasTranslationTemplates.providedBy(self.context):
            raise NotImplementedError(
                'Subclass not implementing `IHasTranslationsTemplates` '
                'interface.  Either override getDefaultFormat implementation '
                'or implement `IHasTranslationsTemplates`.')

        templates = self.context.getCurrentTranslationTemplates()
        if not bool(templates.any()):
            return None
        formats = self.context.getTranslationTemplateFormats()
        format = formats[0]
        if len(formats) > 1:
            self.request.response.addInfoNotification(
                "This package has templates with different native "
                "file formats.  If you proceed, all translations will be "
                "exported in the single format you specify.")
        return format
Ejemplo n.º 3
0
    def processForm(self):
        """Return templates and translations requested to be exported.

        Overridable in a child class.  Must do one of:
        a. Add an error notification to the page and return `None`
        b. Return a tuple of two iterables or None, of requested templates
           and of requested pofiles IDs.
        c. Redirect and return `None`.
        """
        if not IHasTranslationTemplates.providedBy(self.context):
            raise NotImplementedError(
                'Subclass not implementing `IHasTranslationsTemplates` '
                'interface.  Either override getDefaultFormat implementation '
                'or implement `IHasTranslationsTemplates`.')

        translation_templates_ids = (
            self.context.getCurrentTranslationTemplates(just_ids=True))
        pofiles_ids = self.context.getCurrentTranslationFiles(just_ids=True)
        if not bool(pofiles_ids.any()):
            pofiles_ids = None
        return (translation_templates_ids, pofiles_ids)
Ejemplo n.º 4
0
    def processForm(self):
        """Return templates and translations requested to be exported.

        Overridable in a child class.  Must do one of:
        a. Add an error notification to the page and return `None`
        b. Return a tuple of two iterables or None, of requested templates
           and of requested pofiles IDs.
        c. Redirect and return `None`.
        """
        if not IHasTranslationTemplates.providedBy(self.context):
            raise NotImplementedError(
                'Subclass not implementing `IHasTranslationsTemplates` '
                'interface.  Either override getDefaultFormat implementation '
                'or implement `IHasTranslationsTemplates`.')

        translation_templates_ids = (
            self.context.getCurrentTranslationTemplates(just_ids=True))
        pofiles_ids = self.context.getCurrentTranslationFiles(just_ids=True)
        if not bool(pofiles_ids.any()):
            pofiles_ids = None
        return (translation_templates_ids, pofiles_ids)
Ejemplo n.º 5
0
 def pofiles(self):
     """See `ITranslatedLanguage`."""
     assert IHasTranslationTemplates.providedBy(self.parent), (
         "Parent object should implement `IHasTranslationTemplates`.")
     current_templates = self.parent.getCurrentTemplatesCollection()
     return POFilesByPOTemplates(current_templates, self.language)
Ejemplo n.º 6
0
 def pofiles(self):
     """See `ITranslatedLanguage`."""
     assert IHasTranslationTemplates.providedBy(self.parent), (
         "Parent object should implement `IHasTranslationTemplates`.")
     current_templates = self.parent.getCurrentTemplatesCollection()
     return POFilesByPOTemplates(current_templates, self.language)