function lingotek_set_target_language in Lingotek Translation 7.2
Same name and namespace in other branches
- 7.7 lingotek.util.inc \lingotek_set_target_language()
- 7.3 lingotek.util.inc \lingotek_set_target_language()
- 7.4 lingotek.util.inc \lingotek_set_target_language()
- 7.5 lingotek.util.inc \lingotek_set_target_language()
- 7.6 lingotek.util.inc \lingotek_set_target_language()
Sets the extended target language locale in the languages table and whether or not it is enabled
Parameters
$drupal_language_code:
$lingotek_enabled whether or not to enable the language as being lingotek_enabled (default: 1):
$lingotek_locale the lingotek locale that the drupal code should be associated with (it will try to pick the right one when not passed in):
$api_add boolean whether or not to add the language to all documents in the project (default: TRUE):
1 call to lingotek_set_target_language()
- lingotek_add_target_language in ./
lingotek.util.inc - Adds the target language as being enabled.
File
- ./
lingotek.util.inc, line 709 - Utility functions.
Code
function lingotek_set_target_language($drupal_language_code, $lingotek_enabled = 1, $lingotek_locale = NULL, $api_add = TRUE) {
$result = FALSE;
if (is_string($drupal_language_code) && strlen($drupal_language_code)) {
$lingotek_locale = is_null($lingotek_locale) ? Lingotek::convertDrupal2Lingotek($drupal_language_code, FALSE) : $lingotek_locale;
db_update('languages')
->fields(array(
'enabled' => 1,
'lingotek_enabled' => $lingotek_enabled ? 1 : 0,
'lingotek_locale' => $lingotek_locale,
))
->condition('language', $drupal_language_code)
->execute();
watchdog("lingotek", "Target language added: @drupal_language_code", array(
'@drupal_language_code' => $drupal_language_code,
));
if ($lingotek_enabled && $lingotek_locale && $api_add) {
// Add the Target Language to the Lingotek Project.
$project_id = variable_get('lingotek_project', '');
$api = LingotekApi::instance();
$result = $api
->addTranslationTarget(NULL, $project_id, $lingotek_locale);
}
}
return $result;
}