function lingotek_create_path_prefix in Lingotek Translation 7.7
1 call to lingotek_create_path_prefix()
- lingotek_add_target_language in ./lingotek.util.inc
- Adds the target language as being enabled.
File
- ./lingotek.util.inc, line 1161
- Utility functions.
Code
function lingotek_create_path_prefix($drupal_code) {
$prefix = '';
$prefix_without_hyphen = '';
$prefix_with_hyphen = $drupal_code;
if (strpos($drupal_code, '-') !== FALSE) {
$hyphen_pos = strpos($drupal_code, '-');
$prefix_without_hyphen = substr($drupal_code, 0, $hyphen_pos);
}
else {
$prefix_without_hyphen = $drupal_code;
}
$prefixes = db_select('languages', 'l')
->fields('l', array(
'prefix',
))
->execute()
->fetchCol();
$prefix_without_hyphen_used = FALSE;
foreach ($prefixes as $prefix) {
if ($prefix === $prefix_without_hyphen) {
$prefix_without_hyphen_used = TRUE;
break;
}
}
if (!$prefix_without_hyphen_used) {
$prefix = $prefix_without_hyphen;
}
$prefix_with_hyphen_used = FALSE;
if ($prefix_without_hyphen_used) {
foreach ($prefixes as $prefix) {
if ($prefix === $drupal_code) {
$prefix_with_hyphen_used = TRUE;
break;
}
}
if (!$prefix_with_hyphen_used) {
$prefix = $prefix_with_hyphen;
}
}
return $prefix;
}