Skip to content

Translating a document with minification fails if the original file has no media #73

@ideb

Description

@ideb

Problem/Motivation

Deepl support document minification: Deepl document minification: https://github.com/DeepLcom/deepl-php?tab=readme-ov-file#document-minification

However, translating a .docx or .pptx file currently results in an exception when the input file has no media

Steps to reproduce

  1. Create a docx with a single word 'test'
  2. Call \DeepL\Translator::translateDocument with $options[TranslateDocumentOptions::ENABLE_DOCUMENT_MINIFICATION]
  3. Notice the call results in an exception:
    UnexpectedValueException: RecursiveDirectoryIterator::__construct(/var/folders/7c/83djllx9041g_r31cy6w3w280000gn/T/document_minification_693ae127272c6/original_media): Failed to open directory: No such file or directory in RecursiveDirectoryIterator->__construct() (line 309 of vendor/deeplcom/deepl-php/src/DocumentMinifier.php). DeepL\DocumentMinifier->replaceImagesInDir('/var/folders/7c/83djllx9041g_r31cy6w3w280000gn/T/document_minification_693ae127272c6/extracted_doc', '/var/folders/7c/83djllx9041g_r31cy6w3w280000gn/T/document_minification_693ae127272c6/original_media') (Line: 205)

Proposed resolution

Check if the original media directory is available

User interface changes

None

API changes

None

Data model changes

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions