I was asked by one of my clients to rename component type strings (e.g. 'markup' and 'fieldset') as they didn't make sense to non-tech users so I used locale module and translated component type strings. It was possible to translate component type string in most of the parts since the type is put through t() in function webform_load_component() in webform.module as shown below:
if ($return_all || $enabled) {
include_once($filename);
$component_list[$file->name] = t($file->name);
}
if ($enabled) {
$enabled_list[$file->name] = t($file->name);
}
However, when they are displayed as a list in a table in node/[nid]/edit/components, the translated string doesn't appear. This is because the variable responsible in line 183 in webform_components.inc is not put through t():
$component['type'],
By changing this to t($component['type']) translated string will appear when components are displayed in the table.
Comments
Comment #1
quicksketchThanks, even though this is improper use of t(), it's the best we have for the time being. I've wrapped that line in t() as you suggest.
Comment #3
dokumori commentedThanks quicksketch :)
I did wonder whether it's the right way to use t() so before creating this issue I checked the doc (http://api.drupal.org/api/function/t/5 ) and it says:
The only case in which variables can be passed safely through t() is when code-based versions of the same strings will be passed through t() (or otherwise extracted) elsewhere.
so in this case using t() is appropriate.