function i18n_string_translate_check_string in Internationalization 7
Check whether there is any problem for the user to translate a specific string.
Here we assume the user has 'translate interface' access that should have been checked for the page. Possible reasons a user cannot translate a string:
Parameters
$i18nstring: String object.
$account: Optional user account, defaults to current user.
Return value
None or empty string if the user has access to translate the string. Message if the user cannot translate that string.
1 call to i18n_string_translate_check_string()
- i18n_string_object::check_translate_access in i18n_string/
i18n_string.inc - Check whether there is any problem for the user to translate a this string.
File
- i18n_string/
i18n_string.module, line 645 - Internationalization (i18n) package - translatable strings.
Code
function i18n_string_translate_check_string($i18nstring, $account = NULL) {
// Check block translation permissions.
if ($i18nstring->textgroup == 'blocks') {
if (!user_access('translate interface', $account) && !user_access('translate blocks', $account)) {
return t('This is a user-defined string within a block. You are not allowed to translate blocks.');
}
}
elseif (!user_access('translate interface', $account) || !user_access('translate user-defined strings', $account)) {
return t('This is a user-defined string. You are not allowed to translate these strings.');
}
if (!empty($i18nstring->format)) {
if (!i18n_string_allowed_format($i18nstring->format)) {
$format = filter_format_load($i18nstring->format);
return t('This string uses the %name text format. Strings with this format are not allowed for translation.', array(
'%name' => $format->name,
));
}
elseif ($format = filter_format_load($i18nstring->format)) {
// It is a text format, check user access to that text format.
if (!filter_access($format, $account)) {
return t('This string uses the %name text format. You are not allowed to translate or edit texts with this format.', array(
'%name' => $format->name,
));
}
}
else {
// This is one of our special formats, I18N_STRING_FILTER_*
if ($i18nstring->format == I18N_STRING_FILTER_XSS_ADMIN && !user_access('translate admin strings', $account)) {
return t('The source string is an administrative string. You are not allowed to translate these strings.');
}
}
}
// No error message, it should be OK to translate.
return '';
}