How to use the aeidon.documents.TRAN function in aeidon

To help you get started, we’ve selected a few aeidon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github otsaloma / gaupol / aeidon / agents / save.py View on Github external
def save_translation(self, file=None, keep_changes=True):
        """
        Write subtitle data from translation document to `file`.

        `file` can be ``None`` to use :attr:`tran_file`.
        Raise :exc:`IOError` if writing fails.
        Raise :exc:`UnicodeError` if encoding fails.
        """
        file = file or self.tran_file
        if file is not None and self.tran_file is not None:
            file.copy_from(self.tran_file)
        indices = self._save(aeidon.documents.TRAN, file, keep_changes)
        if keep_changes:
            self.tran_file = file
            self.tran_changed = 0
            self.emit("translation-texts-changed", indices)
        self.emit("translation-file-saved", file)
github otsaloma / gaupol / gaupol / agents / save.py View on Github external
def save_translation_as(self, page, file=None):
        """Save the translation document of `page` to a selected file."""
        if file is None:
            file = page.project.tran_file
            file = self._select_file(_("Save Translation As"), page, file)
        self._save_document(page, aeidon.documents.TRAN, file)
        self.emit("page-saved", self, page)
        path = page.project.tran_file.path
        format = page.project.tran_file.format
        self.add_to_recent_files(path, format, aeidon.documents.TRAN)
        self.flash_message(_('Saved translation document as "{}"')
                           .format(os.path.basename(path)))
github otsaloma / gaupol / aeidon / agents / save.py View on Github external
def save(self, doc, file=None, keep_changes=True):
        """
        Write subtitle data from `doc` to `file`.

        `file` can be ``None`` to use existing file.
        Raise :exc:`IOError` if writing fails.
        Raise :exc:`UnicodeError` if encoding fails.
        """
        if doc == aeidon.documents.MAIN:
            return self.save_main(file, keep_changes)
        if doc == aeidon.documents.TRAN:
            return self.save_translation(file, keep_changes)
        raise ValueError("Invalid document: {!r}".format(doc))
github otsaloma / gaupol / gaupol / agents / save.py View on Github external
def save(self, page, doc):
        """Save `doc` of `page` to file."""
        if doc == aeidon.documents.MAIN:
            return self.save_main(page)
        if doc == aeidon.documents.TRAN:
            return self.save_translation(page)
        raise ValueError("Invalid document: {!r}"
                         .format(doc))
github otsaloma / gaupol / gaupol / util.py View on Github external
def text_field_to_document(field):
    """Return :attr:`aeidon.documents` item corresponding to `field`."""
    if field == gaupol.fields.MAIN_TEXT:
        return aeidon.documents.MAIN
    if field == gaupol.fields.TRAN_TEXT:
        return aeidon.documents.TRAN
    raise ValueError("Invalid field: {!r}"
                     .format(field))
github otsaloma / gaupol / gaupol / util.py View on Github external
def text_field_to_document(field):
    """Return :attr:`aeidon.documents` item corresponding to `field`."""
    if field == gaupol.fields.MAIN_TEXT:
        return aeidon.documents.MAIN
    if field == gaupol.fields.TRAN_TEXT:
        return aeidon.documents.TRAN
    raise ValueError("Invalid field: %s" % repr(field))
github otsaloma / gaupol / gaupol / util.py View on Github external
def document_to_text_field(doc):
    """Return :attr:`gaupol.fields` item corresponding to `doc`."""
    if doc == aeidon.documents.MAIN:
        return gaupol.fields.MAIN_TEXT
    if doc == aeidon.documents.TRAN:
        return gaupol.fields.TRAN_TEXT
    raise ValueError("Invalid document: {!r}"
                     .format(doc))
github otsaloma / gaupol / gaupol / agents / open.py View on Github external
def open_translation(self, path, encoding=None, align_method=None):
        """Open file at `path` as a translation file."""
        if align_method is not None:
            gaupol.conf.file.align_method = align_method
        encodings = self._get_encodings(encoding)
        page = self._open_file(path, encodings, aeidon.documents.TRAN)
        gaupol.util.set_cursor_busy(self.window)
        col = page.view.columns.TRAN_TEXT
        if not page.view.get_column(col).get_visible():
            self.get_column_action(gaupol.fields.TRAN_TEXT).activate()
        format = page.project.tran_file.format
        self.add_to_recent_files(path, format, aeidon.documents.TRAN)
        gaupol.util.set_cursor_normal(self.window)
github otsaloma / gaupol / aeidon / agents / set.py View on Github external
def set_translation_text(self, index, value, register=-1):
        """Set the value of translation document's text."""
        return self.set_text(index,
                             aeidon.documents.TRAN,
                             value,
                             register=register)
github otsaloma / gaupol / gaupol / agents / preview.py View on Github external
    @aeidon.deco.export
    def _on_preview_activate(self, *args):
        """Preview from selected position with a video player."""
        page = self.get_current_page()
        rows = page.view.get_selected_rows()
        row = rows[0] if rows else 0
        position = page.project.subtitles[row].start
        col = page.view.get_focus()[1]
        if col == page.view.columns.TRAN_TEXT:
            doc = aeidon.documents.TRAN
        else: # Any other column previews the main file.
            doc = aeidon.documents.MAIN
        self.preview(page, position, doc)