I'm developing a simple module with and admin page, where admin can fill some textfields with custom strings that will generates a piece of html to be used later.
So for example I have fields like this in admin page:
function MYMODULE_admin_page_arguments() {
$form = array();
$form['MYMODULE_link'] = array(
'#type' => 'textfield',
'#title' => t('Conditions link path'),
'#default_value' => variable_get('MYMODULE_link', 'conditions'),
);
$form['MYMODULE_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Conditions link text'),
'#default_value' => variable_get('MYMODULE_link_text', 'conditions'),
);
$form['MYMODULE_link_target'] = array(
'#type' => 'textfield',
'#title' => t('Conditions link target'),
'#default_value' => variable_get('MYMODULE_link_target', '_blank'),
);
$form['MYMODULE_prefix'] = array(
'#type' => 'textfield',
'#title' => t('Conditions link prefix text'),
'#default_value' => variable_get('MYMODULE_prefix', 'I agree to the '),
);
$form['MYMODULE_suffix'] = array(
'#type' => 'textfield',
'#title' => t('Conditions link suffix text'),
'#default_value' => variable_get('MYMODULE_suffix', '.'),
);
return system_settings_form($form);
}
Then the above values are managed after by my module to compose an output like:
// Create label
$prefix = variable_get('MYMODULE_prefix', 'I agree to the ');
$suffix = variable_get('MYMODULE_suffix', '.');
$path = variable_get('MYMODULE_link', 'conditions');
$text = variable_get('MYMODULE_link_text', 'conditions');
$target = variable_get('MYMODULE_link_target', '_blank');
$label = $prefix . l($text, $path, array('attributes' => array('target' => $target))) . $suffix;
Now I need that all these values are available for string translation, so the first think I thought was to pass all of them through t(), for example:
$label = t($prefix) . l(t($text), $path, array('attributes' => array('target' => $target))) . t($suffix);
but I read here https://api.drupal.org/api/drupal/includes!bootstrap.inc/function/t/7 that I should never pass variables directly to t(), so for e.g t($prefix) is a bad stuff.
So, what is the correct Drupal way to accomplish this?