Skip to content

Commit

Permalink
Switch order of methods
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskonnertz committed Oct 2, 2017
1 parent b041501 commit de3f14d
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/ChrisKonnertz/DeepLy/DeepLy.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,24 +104,6 @@ public function __construct()
$this->httpClient = new CurlHttpClient($this->protocol);
}

/**
* Tries to detect the language of a text and returns its language code.
* The language of the text has to be one of the supported languages or the result will be incorrect.
* This method might throw an exception so you should wrap it in a try-catch-block.
*
* @param string $text The text you want to analyze
* @return string|null Returns a language code from the self::LANG_CODES array or null
* @throws \Exception
*/
public function detectLanguage($text)
{
// Note: We always use English as the target language. if the source language is English as well,
// DeepL automatically seems to set the target language to French so this is not a problem.
$translationBag = $this->requestTranslation($text, self::LANG_EN);

return $translationBag->getSourceLanguage();
}

/**
* Uses the DeepL API to split a text into a string array of sentences.
*
Expand Down Expand Up @@ -158,6 +140,24 @@ public function splitText($text, $from = self::LANG_AUTO)
return $sentences;
}

/**
* Tries to detect the language of a text and returns its language code.
* The language of the text has to be one of the supported languages or the result will be incorrect.
* This method might throw an exception so you should wrap it in a try-catch-block.
*
* @param string $text The text you want to analyze
* @return string|null Returns a language code from the self::LANG_CODES array or null
* @throws \Exception
*/
public function detectLanguage($text)
{
// Note: We always use English as the target language. if the source language is English as well,
// DeepL automatically seems to set the target language to French so this is not a problem.
$translationBag = $this->requestTranslation($text, self::LANG_EN);

return $translationBag->getSourceLanguage();
}

/**
* Requests a translation from the API. Returns a TranslationBag object.
* ATTENTION: The target language parameter is followed by the source language parameter!
Expand Down

0 comments on commit de3f14d

Please sign in to comment.