I have a select field in the panel where I implemented translation directly in the blueprint like described in the docs.
In my case, the field are several categories for a FAQ stored as Question-Pages - like “About us” or “Service ABC”.
When displaying the FAQ categories in the FAQ template, I use a nested foreach loop to go through the categories and questions for each category:
// Group all questions per category
$categories = page('faq')->children()->groupBy('category');
foreach($categories as $category => $questionsPerCategory):?>
<div><h5><?= ucwords($category, " \t\r\n\f\v\-") ?></h5></div>
<?php $catID++; endforeach ?>
When I now output the $category, it always displays the definition of the select option as defined in the question page, not the translation (as it does in the panel).
Is there an easy way to access the translation? I tried the cookbook recipe for accessing field options but could not wrap my head around the idea of how to make this work without actually accessing the actual page.
Yes, that’s what you’d have to do, so get the translations from $category->blueprint(). Might make sense to only do this once. Or store what you have in your blueprint in the language translations and get it from there. Which would mean duplicating the work you have done in the blueprints, but I think the performance is better.
Thanks but this option is real ugly. I need to manually convert strings to uppercase because for whatever reason the category is outputted in lowercase but the array keys are not so that leads to things like