Here’s the filter incorporating @texnixe’s helpful input:
// Anything that matches a given language attribute
collection::$filters['languageIs'] = function($collection, $field, $value) {
foreach($collection->data as $key => $item) {
if (collection::extractValue($item->content()->language(), $field) != $value) {
unset($collection->$key);
}
}
return $collection;
};
Add this to your site/plugin/filters.php
and use the following in your templates:
$articles = $page->children()->visible()->filterBy('code', 'languageIs', 'ja');
Thanks,
Moritz