Google\Cloud\Translate\TranslateClient::localizedLanguages PHP Method

localizedLanguages() public method

Unlike {@see \Google\Cloud\Translate\TranslateClient::languages()} this will return the localized language names in addition to the ISO 639-1 language codes. Example: $languages = $translate->localizedLanguages(); foreach ($languages as $language) { echo $language['code']; }
See also: https://cloud.google.com/translate/v2/discovering-supported-languages-with-rest Discovering Supported Languages
public localizedLanguages ( array $options = [] ) : array
$options array [optional] { Configuration Options. @type string $target The language to discover supported languages for. Must be a valid ISO 639-1 language code. **Defaults to** the value assigned to the client (`"en"` by default). }
return array A set of language results. Each result includes a `code` key containing the ISO 639-1 code for the supported language and a `name` key containing the name of the language written in the target language.
    public function localizedLanguages(array $options = [])
    {
        $response = $this->connection->listLanguages($options + ['key' => $this->key, 'target' => $this->targetLanguage]);
        return array_map(function ($language) {
            return array_filter(['code' => $language['language'], 'name' => isset($language['name']) ? $language['name'] : null]);
        }, $response['data']['languages']);
    }