2

Is it possible to have the labels for any of these fields be translatable in templates? I don't mean make the whole field translatable - the same option values would be shared between locales, I would just like the output the label in the correct language.

5

Use the translate (or t) filter:

{{label|t}}

See how to translate static text in templates

| improve this answer | |
  • Brilliant, works perfectly. I didn't think it would work unless it was an actual string like {{ "Something"|t }}. – Patrick Nesbitt Sep 11 '14 at 1:27
2

Using the LJ Dynamic Fields plugin, you can also generate drop-down, checkbox, multi-select, and radio button labels/values dynamically from a another channel. If the lookup channel data is localized then the labels will be also. I implemented this for a localized drop-down country list. Works great! and client can control the entries. Powerful plugin.

{% for entry in craft.entries.section('countries').limit(null).order('countryName') %}
  { "value":"{{ entry.countryCode }}" , "label":"{{ entry.countryName }}"}
  {% if not loop.last %},{% endif %}
{% endfor %}
| improve this answer | |
  • this is an excellent idea – mjr Jan 12 '16 at 22:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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