How can I get translated path aliases for a custom language switcher?
Seems you can do what you want with Url options and a language object like following.

// Get all activated languages.
$languages = \Drupal::languageManager()-&gt;getLanguages();

foreach ($languages as $language) {

  // Get the current URL in each language.
  $url = \Drupal\Core\Url::fromRoute('&lt;current&gt;')
    -&gt;setOption('language', $language)-&gt;toString();

  // And add it to a custom array.
  $variables['my_langswitch'][$language-&gt;getId()] = $url;
}


But as I already said in the comments to your question, this should actually be put in a custom block. And since it's all just about a little bit of changing markup I'd even go for JavaScript here and stick to the built-in language switcher. Also as I'm not sure how above works with caching enabled.



If you prefer getting the paths one-by-one, get a language object first and then use that to get the path alias.

// Get Swedish language
if ($sv_language = \Drupal::languageManager()-&gt;getLanguage('sv')) {

  // Get Swedish URL.
  $sv_url = \Drupal\Core\Url::fromRoute('&lt;current&gt;')
    -&gt;setOption('language', $sv_language)-&gt;toString();

  // Add it as custom variable.
  $variables['sv_url'] = $sv_url;
}