1

Lets say i have table field with product technical specification - two columns, one for feature name, one for feature value.

Feature name (for example - "weight") needs to be translated across various languages. Feature value needs to always stay the same (for xample - "1kg").

How can this be achieved?

2

If there’s a predetermined set of feature names, then you could translate them using static message translations.

{% for row in entry.myTableField %}
  <dt>{{ row.featureName|t }}</dt>
  <dd>{{ row.featureValue }}</dd>
{% endfor %}

If new products will always be introducing new feature names, then that might become impractical, as you’d be constantsly adding new values to your translation file.

You could set up a custom translation message source + category in config/app.php that pulls translations in from a separate, translatable Table field on a Global Set, for instance, but that could be overkill.

The other option is to use Verbb’s Super Table plugin, which will let you mark certain fields as translatable.

2
  • Thanks for reply. Unfortunetly every product will have different options. So only viable solution is using that plugin, although im little anxious of basing my db content on external plugins. Do you plan on adding this feature to future versions of craft? Its not the first time i encoured this problem. – Ded Nolyxeux Aug 7 '18 at 14:29
  • @DedNolyxeux Verbb is a super solid developer and Super Table is a popular plugin, so it’s a safe bet. If you want to stick with a native solution you could use a Matrix field. – Brandon Kelly Aug 7 '18 at 15:20

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.