function rt in Views Bulk Operations (VBO) 6
Same name and namespace in other branches
Reverse translation: find English string given translated string. WARNING: Will not work for strings with params.
1 call to rt()
File
- ./
actions_permissions.module, line 46
Code
function rt($string) {
global $language;
$langcode = $language->language;
// 1. Lookup custom strings.
static $custom_strings;
if (!isset($custom_strings[$langcode])) {
$custom_strings[$langcode] = variable_get('locale_custom_strings_' . $langcode, array());
}
if ($source = array_search($string, $custom_strings[$langcode])) {
return $source;
}
// 2. Lookup locale translations.
if (!function_exists('locale') || $langcode == 'en') {
return $string;
}
if (variable_get('locale_cache_strings', 1) == 1) {
// Cache is on: this string is in the static cache for sure since we have its translated version.
$locale_t = locale();
if (isset($locale_t[$langcode]) && ($source = array_search($string, $locale_t[$langcode], TRUE))) {
return $source;
}
else {
return $string;
}
}
else {
// Cache is off: look it up in the database.
$source = db_result(db_query("SELECT s.source FROM {locales_source} s LEFT JOIN {locales_target} t ON s.lid = t.lid AND t.language = '%s' WHERE t.translation = '%s' AND s.textgroup = 'default'", $langcode, $string));
return $source ? $source : $string;
}
}