src/ChrisKonnertz/DeepLy/DeepLy.php
public function translateFile($filename, $to = self::LANG_EN, $from = self::LANG_AUTO)
    {
        if (! is_string($filename)) {
            throw new \InvalidArgumentException('The $filename argument has to be a string');
        }
        if (! is_readable($filename)) {
            throw new \InvalidArgumentException('Could not read file with the given filename');
        }

        $text = file_get_contents($filename);

        if ($text === false) {
            throw new \RuntimeException(
                'Could not read file with the given filename. Does this file exist and do we have read permission?'
            );
        }

        return $this->translate($text, $to, $from);
    }
public function translateFile($filename, $to = self::LANG_EN, $from = self::LANG_AUTO)
    {
        if (! is_string($filename)) {
            throw new \InvalidArgumentException('The $filename argument has to be a string');
        }
        if (! is_readable($filename)) {
            throw new \InvalidArgumentException('Could not read file with the given filename');
        }

        $text = file_get_contents($filename);

        if ($text === false) {
            throw new \RuntimeException(
                'Could not read file with the given filename. Does this file exist and do we have read permission?'
            );
        }

        return $this->translate($text, $to, $from);
    }
Translates a text file. The $from argument is optional.
ATTENTION: The target language parameter is followed by the source language parameter!
This method will throw an exception if reading the file or translating fails
so you should wrap it in a try-catch-block.

@param string      $filename The name of the file you want to translate
@param string      $to       Optional: The target language, a self::LANG_<code> constant
@param string|null $from     Optional: The source language, a self::LANG_<code> constant
@return string|null          Returns the translated text or null if there is no translation
@throws \Exception