You are here

function lingotek_add_target_language in Lingotek Translation 7.2

Same name and namespace in other branches
  1. 7.7 lingotek.util.inc \lingotek_add_target_language()
  2. 7.3 lingotek.util.inc \lingotek_add_target_language()
  3. 7.4 lingotek.util.inc \lingotek_add_target_language()
  4. 7.5 lingotek.util.inc \lingotek_add_target_language()
  5. 7.6 lingotek.util.inc \lingotek_add_target_language()

Adds the target language as being enabled.

2 calls to lingotek_add_target_language()
lingotek_dashboard_command_ajax in ./lingotek.dashboard.inc
Ajax Command Processing for the Lingotek dashboard.
lingotek_migration_1 in ./lingotek.util.inc

File

./lingotek.util.inc, line 757
Utility functions.

Code

function lingotek_add_target_language($lingotek_locale, $call_api = TRUE) {
  lingotek_add_missing_locales();

  // fills in any missing lingotek_locale values to the languages table
  $language = lingotek_lookup_language_by_locale($lingotek_locale);
  if ($language) {

    // If already in the languages table then just tack on the lingotek_locale and enable it
    $drupal_language_code = $language->language;
  }
  else {

    // If not add it to the languages table first and then tack on the lingotek_locale and enable it
    $drupal_language_code = Lingotek::convertLingotek2Drupal($lingotek_locale, FALSE);
    if (!lingotek_lookup_locale_exists($drupal_language_code)) {
      $name = isset($_POST['language']) ? $_POST['language'] : NULL;
      $native = isset($_POST['native']) ? $_POST['native'] : NULL;
      $direction = isset($_POST['direction']) && strcasecmp('RTL', $_POST['direction']) == 0 ? LANGUAGE_RTL : LANGUAGE_LTR;
      $domain = '';
      $prefix = '';

      //to-do: attempt to use a short prefix
      locale_add_language($drupal_language_code, $name, $native, $direction, $domain, $prefix);

      // Function from the Locale module.
    }
  }
  lingotek_add_target_sync_status_to_all_nodes($lingotek_locale);

  // Add the node sync target language entries to the lingotek table.
  return lingotek_set_target_language($drupal_language_code, 1, $lingotek_locale, $call_api);
}