function i18n_get_path_translations in Internationalization 7
Get translations for path.
Parameters
$path: Path to get translations for or '<front>' for front page.
$check_access: Whether to check access to paths, defaults to TRUE
2 calls to i18n_get_path_translations()
- i18n_language_switch_links_alter in ./
i18n.module - Implements hook_language_switch_links_alter().
- i18n_redirect_init in i18n_redirect/
i18n_redirect.module - Implements hook_init()
File
- ./
i18n.module, line 513 - Internationalization (i18n) module.
Code
function i18n_get_path_translations($path, $check_access = TRUE) {
$translations =& drupal_static(__FUNCTION__);
if (!isset($translations[$path])) {
$translations[$path] = array();
foreach (module_implements('i18n_translate_path') as $module) {
$translated = call_user_func($module . '_i18n_translate_path', $path);
// Add into the array, if two modules returning a translation first takes precedence.
if ($translated) {
$translations[$path] += $translated;
}
}
// Add access information if not there.
foreach ($translations[$path] as $langcode => &$info) {
if (!isset($info['access'])) {
$item = menu_get_item($info['href']);
// If no menu item, it may be an external URL, we allow access.
$info['access'] = $item ? !empty($item['access']) : TRUE;
}
}
// Chance for altering the results.
drupal_alter('i18n_translate_path', $translations[$path], $path);
}
if ($check_access) {
return array_filter($translations[$path], '_i18n_get_path_translations_access');
}
else {
return $translations[$path];
}
}