You mean a code like this?
<nav class="languages">
<ul>
<?php
$translatedPages = $page->isActive()->children()->filter(function ($child) {
return $child->translation(kirby()->language()->code())->exists();
});?>
<?php if ($translatedPages->isTrue()): ?><?= svg('assets/icons/language-base20.svg') ?> <?php endif ?>
<?php foreach($kirby->languages()->not($kirby->language()) as $language): ?>
<?php if ($page->translation($language->code())->exists()): ?>
<li<?php e($kirby->language() == $language, ' class="active"') ?>>
<a href="<?= $page->url($language->code()) ?>" hreflang="<?php echo $language->code() ?>">
<?= html($language->name()) ?>
</a>
</li>
<?php endif ?>
<?php endforeach ?>
</ul>
</nav>