1

I have a site for a company that is established in US markets and expanding into markets overseas. The site has products and those products are grouped into categories.

Due to the costs of translating content, the client has opted to translate some of their product content but not all of it. Out of 8 categories of products, only 2 of those categories have been translated.

Category 1 => translated
Category 2
Category 3
Category 4
Category 5 => translated
Category 6
Category 7
Category 8

As far as I can tell, there is no way to output only a list of categories that have been translated in a specific locale. Unlike entries, Categories don't appear to have a way to be enabled or disabled - they are all active for all locales.

Am I missing anything? Or has anybody come up with a way to display only translated categories? Ideally, in the secondary locale, I would be able to display a list of only the two categories that have been translated:

Category 1 => translated
Category 5 => translated
3

Correct, categories don’t have the same localization features that entries do, as it is expected that all categories will always live in all locales. And Craft doesn’t actually keep a record of which content has been directly translated, vs. which content was just copied over to a locale when one of the other locales was edited.

If you really want to only show the categories that have been translated, you’d have to add a custom “Translated” Lightswitch field to your category group’s field layout (which would be translatable so each locale gets its own value), and then factor it into any category queries:

craft.categories.group('groupHandle').translated(1)
  • Thanks. I ended up implementing this solution. In this case, since all of the content is translated into every locale it works out. If different content was translated into each locale, I think things would get a little trickier as we'd start to add a new lightswitch for each locale, similar to the entries locale settings. The general assumption of all categories being translated is probably accurate, however in this case, it was a reasonable decision to not translate all content due to costs and the experience on the site improves if we are only displaying translated content. – Ben Parizek Dec 22 '15 at 3:55

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.