You are here

public function Lingotek::getLocalesInfo in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 4.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  2. 3.0.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  3. 3.1.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  4. 3.2.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  5. 3.3.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  6. 3.4.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  7. 3.5.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  8. 3.6.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  9. 3.7.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()
  10. 3.8.x src/Lingotek.php \Drupal\lingotek\Lingotek::getLocalesInfo()

Get the available locales on Lingotek.

Return value

array Array of locales. Empty array if there is an error. The array has the locale as key, and the value is a nested array with the following keys: code, language_code, title, language, country_code, and country.

Overrides LingotekInterface::getLocalesInfo

File

src/Lingotek.php, line 514

Class

Lingotek
The connecting class between Drupal and Lingotek

Namespace

Drupal\lingotek

Code

public function getLocalesInfo() {
  $data = $this->api
    ->getLocales();
  $locales = [];
  if ($data) {
    foreach ($data['entities'] as $locale) {
      $languageCode = $locale['properties']['language_code'];
      $countryCode = $locale['properties']['country_code'];
      $title = $locale['properties']['title'];
      $language = $locale['properties']['language'];
      $country = $locale['properties']['country'];
      $code = $locale['properties']['code'];
      $locales[$code] = [
        'code' => $code,
        'language_code' => $languageCode,
        'title' => $title,
        'language' => $language,
        'country_code' => $countryCode,
        'country' => $country,
      ];
    }
  }
  return $locales;
}