Translating CCK Field Options

When building a multilingual site, it's important to ensure that the entire interface can be translated. All kinds of site elements are thrown into the mix including taxonomy terms, block titles, views labels, and dates.

Another important element is cck fields. While the labels and descriptions of cck fields are automatically passed through the translation function, options for these fields are not. These are the "allowed values" you enter when creating checkboxes, selectboxes or radio buttons.

In order to be able to translate these strings through Drupal, you need to expand the "PHP Code" fieldset when configuring the cck field. Then, include an array of key value pairs, with the value wrapped in the translation function.

return array(
'Per Course' => t('Per Course'),
'Per Year' => t('Per Year'),
'Per Generation' => t('Per Generation (for multi-year programs)')
);

Tags:

Comments

Thanks for this hint. It has been useful to me.

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options