2

I am working on a multi-lingual site that contains a few sections in 5 languages (de, en, es, fr, ja). Most of the content however exists only in two languages (de, en). For regular content sections I can indicate which locales should be available. However, I could not find a way to limit the locales for asset meta fields in a similar way.

Background: Why do I want to limit the number of locales?

My site contains a large number of product descriptions. Each product description can have multiple assets. Each asset has a (non-translatable) type (e.g. image, PDF, audio sample) and a (translatable) caption. The captions exist only in the de and en locales. When I import the assets in craft (with a plugin), a content entry for every locale will be created and this leads to a very bloated content table.

  • Can I just delete the unwanted entries in the content table?
  • Should I use a different setup for storing assets (e.g. a special content section with a file field and not asset meta fields)?

Any help is highly appreciated. Thank you.

2

Can I just delete the unwanted entries in the content table?

No, definitely don’t do that.

If you only want to enter captions in a couple languages, fine. Just ignore the other locales.

Then from your templates you can always have Craft fetch the assets with the DE or EN content, by setting the locale param.

{% set assetLocale = (craft.locale == 'en' ? 'en' : 'de') %}

{% for asset in entry.myAssetsField.locale(assetLocale) %}
    {{ asset.caption }}
{% endfor %}
  • Thank you very much for your answer. I was wondering if I should just leave the assets as is and create a separate entry that contains a reference to the file and the metadata. – Christoph Kepper Oct 2 '14 at 10: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.