Filter child pages by available translations

So, @FabianSperrle, here is the custom filter I added to /site/plugins/filters.php:

collection::$filters['languageIs'] = function($collection, $field, $value) {

  foreach($collection->data as $key => $item) {
    // if(str::startsWith(collection::extractValue($item, $field), $value)) continue;
    if (collection::extractValue(collection::extractValue(collection::extractValue($item, 'content'), 'language'), $field) != $value){
      unset($collection->$key);
    }
  }

  return $collection;

};

You then can filter by language with, for example, this:

$page->children()->filterBy('code', 'languageIs', 'ja')

Have fun,
Moritz

P.S. @distantnative and @texnixe: the solution above does not looks very performant to my eyes. If you have and input on optimizations, I’m eager to listen up. Even though I’m still convinced, Kirby core should expose language fields to filterBy by default.