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)')
);

Étiquettes: i18n, Drupal, CCK, Drupal Planet

Back to Blog

Commentaires

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

Poster un nouveau commentaire

Le contenu de ce champ sera maintenu privé et ne sera pas affiché publiquement.
  • Les adresses de pages web et de messagerie électronique sont transformées en liens automatiquement.
  • Tags HTML autorisés : <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Les lignes et les paragraphes vont à la ligne automatiquement.

Plus d'informations sur les options de formatage