1

I have created Boolean fields. I have set values 0/1 in database and No/Yes as labels to display in UI. But I cannot translate these labels. I have translated strings "Yes" and "No" using UI on link admin/config/regional/translate/translate but it does not work for field labels.

Can anybody help?

thanks Tomas

0

2 Answers 2

4

I'm relatively new to Drupal but I've had the same problem recently and this is how I solved it:

  • install the i18n module and enable the "field translation" sub-module (and its dependencies).
  • in the boolean field settings (admin/structure/types/manage/[your-content-type]/fields and click the edit link next to the field) make sure you have specified a value for the On and Off states (e.g. Yes/No).
  • then on the same page (boolean field settings), use the translate tab (on top of the page) and click "translate" for each language you need:
  • under the Field instance tab, you can translate the label for the field.
  • under the Field settings tab, you can translate the values for the On/Off states.
  • lastly (and this is perhaps the less obvious step), go to manage display (for your content type), and as "format" for you boolean field, choose "Default translated" instead of "Default".

Hope this helps.

2
  • I think steps 3-6 aren’t needed.
    – AgA
    Apr 7, 2015 at 8:57
  • This procedure works, but it has to be repeated for every Bool field you want to translate. Aug 16, 2018 at 16:19
0

Try in field management Allowed values PHP code

return array(
  0 => t('No'),
  1 => t('Yes'),
);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.