public static function Lingotek::convertLingotek2Drupal in Lingotek Translation 7.7
Same name and namespace in other branches
- 7.2 lib/Drupal/lingotek/Lingotek.php \Lingotek::convertLingotek2Drupal()
- 7.3 lib/Drupal/lingotek/Lingotek.php \Lingotek::convertLingotek2Drupal()
- 7.4 lib/Drupal/lingotek/Lingotek.php \Lingotek::convertLingotek2Drupal()
- 7.5 lib/Drupal/lingotek/Lingotek.php \Lingotek::convertLingotek2Drupal()
- 7.6 lib/Drupal/lingotek/Lingotek.php \Lingotek::convertLingotek2Drupal()
Gets the Drupal language code for the specified Lingotek language code.
Parameters
string $lingotek_locale: A Lingotek language code. (e.g., 'de_DE', 'pt_BR', 'fr_FR')
bool $enabled_check: Whether or not the languages table should used for lookup (use the code in the table), otherwise perform the standard conversion (e.g., de_DE => de-de)
Return value
mixed The Drupal language code if there is a match for the passed language code, (e.g., 'de-de', 'pt-br',' fr-fr') FALSE otherwise.
14 calls to Lingotek::convertLingotek2Drupal()
- Lingotek::testConvertFunctions in lib/
Drupal/ lingotek/ Lingotek.php - LingotekConfigSet::downloadTriggered in lib/
Drupal/ lingotek/ LingotekConfigSet.php - Updates the local content of $target_code with data from a Lingotek Document
- LingotekSync::getDirtySetLids in lib/
Drupal/ lingotek/ LingotekSync.php - LingotekSync::getEntitySourceCount in lib/
Drupal/ lingotek/ LingotekSync.php - LingotekSync::getEntityTargetCountByStatus in lib/
Drupal/ lingotek/ LingotekSync.php - Get a count of translation targets by entity and status.
File
- lib/
Drupal/ lingotek/ Lingotek.php, line 278 - Defines Lingotek.
Class
- Lingotek
- A utility class for Lingotek translation.
Code
public static function convertLingotek2Drupal($lingotek_locale, $enabled_check = TRUE) {
$drupal_language_code = strtolower(str_replace("_", "-", $lingotek_locale));
// standard conversion
$drupal_general_code = strpos($drupal_language_code, '-') !== FALSE ? substr($drupal_language_code, 0, strpos($drupal_language_code, '-')) : $drupal_language_code;
$languages = language_list();
if (!$enabled_check) {
$exceptions = variable_get('lingotek_mapping_l2d_exceptions', self::$language_mapping_l2d_exceptions);
if (array_key_exists($lingotek_locale, $exceptions)) {
return $exceptions[$lingotek_locale];
}
foreach ($languages as $target) {
if ($target->language == $drupal_language_code) {
return $target->language;
}
}
return $drupal_general_code;
}
$ret = FALSE;
// check to see if the lingotek_locale is set in the drupal languages table
foreach ($languages as $target) {
if (isset($target->lingotek_locale) && strcmp($target->lingotek_locale, $lingotek_locale) == 0) {
return $target->language;
}
}
$exists = array_key_exists($drupal_general_code, $languages);
if ($exists) {
$ret = $drupal_general_code;
}
// if neither the lingotek_locale is set nor the general code exists, then check the code mapping (degraded)
$ltk_to_drupal = array_flip(self::$language_map);
if (isset($ltk_to_drupal[$lingotek_locale])) {
$drupal_language_code = $ltk_to_drupal[$lingotek_locale];
$exists = array_key_exists($drupal_language_code, $languages);
if ($exists) {
$ret = $drupal_language_code;
}
}
return $ret;
}