This is a lot closer. The switcher now will not display the link if the entry is not enable for other site. The index part isn't perfectI think I might finally have it working. If you go to /blog and change the languagesomeone has a more elegant way to for example german it will work: /blog/de. But then if you switchhandle the language againindex, tag and category I would love to for example frenchsee it will go to /fr/de/blog!
<!-- entry -->
{% if entry is defined %}
{% for siteForEntry in entry.getSupportedSites %}
{% set site = craft.app.getSites.getSiteById(siteForEntry.siteId) %}
{% if site.id != entry.siteId %}
{% set entryForOtherSite = craft.entries.id(entry.id).site(site).one() %}
{% if entryForOtherSite is not null %}
<a href="{{ entryForOtherSite.getUrl() }}">{{ site.languagename }}</a>
{% endif %}
{% endif %}
{% endfor %}
<!-- category -->
{% elseif category is defined %}
{% set sites = craft.app.sites.getAllSites() %}
{% for site in sites %}
<li><a href="{{ site.baseUrl }}blog/category/{{craft.request.getLastSegment()}}">{{ site.name }}</a></li>
{% endfor %}
<!-- index and tags -->
{% else %}
{% set localizedUrlsArraysites = seomaticcraft.helperapp.getLocalizedUrlssites.getAllSites() %}
{% for localizedUrlssite in localizedUrlsArraysites %}
<a<li><a href="{{ localizedUrls['url']site.baseUrl }}">{% for segment in craft.request.getSegments() %}{{segment}}/{% localizedUrls['language']endfor %}">{{ site.name }}</a>a></li>
{% endfor %}
{% endif %}