Translate a collection


I’ve got a collection (/site/collections/myCollection.php) which return a list of categories. I call this collection to populate check boxes in a template page and in a blueprint.

I need to translate these categories but have no idea how to proceed. Do you have any advises?

What does your collection look like? An array of key/value pairs? For the frontend, you could either use a nested array with keys for each language and the key/value pairs as nested arrays, or you could use translation strings.

Hello Sonia,

My collection return a Pages object. I use the page title as a label for my checkboxes.

Thanks for your suggestion, it could be a solution for the front part. For the panel, it seems complicated. I can switch my website to a multilingual website to translate my categories pages but do this just to translate my collection seems an overkill solution.

So you are translating content without having a multi-language site? How do translations work, then?

If it’s the only translated content of the website and it isn’t a multilingual site, where and when do you show those translations? People either can switch the language on the frontend (which makes this a multilingual site) or you show several languages alongside each other, in that case you probably want some “title_fr” / “title_de” text fields in your blueprint. Or directly rename the category names to contain all translations:
☐ Dogs · Chiens · Hunde
☒ Cats · Chats · Katzen
☐ Birds · Oiseaux · Vögel