Monday, August 25, 2008

Multilingual CCK node form gotcha

Here's something to consider when building CCK node forms for multilingual sites: if you're providing an allowed values list for radios or checkboxes, use the PHP code box instead of the 'allowed values list' box. So instead of doing this inside the latter:
0|No
1|Yes
... do this instead inside the PHP code box:
return array(0=>t('No'), 1=>t('Yes'));
This way, you get the option texts indexed by the translation mechanism and allows it to pick the right labels for your radios/checkboxes when your user switches languages.

We had to work on lots of large CCK content types for a site with English, French and Spanish content and luckily we tested everything with a small form first. Saved us a huge amount of going back and redoing the boring job of reformatting the allowed values list of about 170 multiple-choice questions... which would have been a real pain in the derrier!

0 comments: