Translate/src/TranslateClient.php
public function detectLanguageBatch(array $strings, array $options = [])
    {
        $response =  $this->connection->listDetections($options + [
            'q' => $strings,
            'key' => $this->key
        ]);

        $detections = [];

        foreach ($response['data']['detections'] as $key => $detection) {
            $detection = $detection[0];

            $detections[] = array_filter([
                'languageCode' => $detection['language'],
                'input' => $strings[$key],
                'confidence' => isset($detection['confidence']) ? $detection['confidence'] : null
            ]);
        }

        return $detections;
    }
public function detectLanguageBatch(array $strings, array $options = [])
    {
        $response =  $this->connection->listDetections($options + [
            'q' => $strings,
            'key' => $this->key
        ]);

        $detections = [];

        foreach ($response['data']['detections'] as $key => $detection) {
            $detection = $detection[0];

            $detections[] = array_filter([
                'languageCode' => $detection['language'],
                'input' => $strings[$key],
                'confidence' => isset($detection['confidence']) ? $detection['confidence'] : null
            ]);
        }

        return $detections;
    }
public function detectLanguageBatch ( array $ strings , array $ options = [ ] ) { $ response = $ this -> connection -> listDetections ( $ options + [ 'q' => $ strings , 'key' => $ this -> key ] ) ; $ detections = [ ] ; foreach ( $ response [ 'data' ] [ 'detections' ] as $ key => $ detection ) { $ detection = $ detection [ 0 ] ; $ detections [ ] = array_filter ( [ 'languageCode' => $ detection [ 'language' ] , 'input' => $ strings [ $ key ] , 'confidence' => isset ( $ detection [ 'confidence' ] ) ? $ detection [ 'confidence' ] : null ] ) ; } return $ detections ; }
Detect the language of multiple strings.

Example:
```
$results = $translate->detectLanguageBatch([
'Hello World!',
'My name is David.'
]);

foreach ($results as $result) {
echo $result['languageCode'];
}
```

@see https://cloud.google.com/translation/v2/detecting-language-with-rest Detecting Langauge

@param string $string The string to detect the language of.
@param array $options [optional] Configuration Options.
@return array A set of results. Each result includes a `languageCode` key
containing the detected ISO 639-1 language code, an `input` key
containing the original string, and in most cases a `confidence`
key containing a value between 0 - 1 signifying the confidence of
the result.
Detect the language of multiple strings .