How to get language prefix in Drupal 8 I am building internal in my custom module that I am porting to Drupal 8:
https://www.drupal.org/project/taxonomy_facets

I need to get a current language prefix so I can prepend it to the link. I Drupal 7 it was as simple as:

global $language;
$prefix = $language-&gt;prefix;
$mylink = $prefix . '/example/something';


How can do this in Drupal 8?

EDIT: My issue specifically is that I have a language prefix set to NONE for the default language at Home &gt;&gt; Administration &gt;&gt; Configuration &gt;&gt; Regional and language &gt;&gt; Languages &gt;&gt; Detection and selection. (admin/config/regional/language/detection/url)

For the default language, I want the code to return the real prefix, i. e. NONE, not en (the code for the default language, English).
In Drupal 8, you use the languageManager class to get the language code:

$languagecode = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();


EDIT: If you want to return NONE if the current language is the default language, you probably need to make a helper function:

$languagecode = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();
$default_languagecode = \Drupal::languageManager()-&gt;getDefaultLanguage()-&gt;getId();
if ($languagecode == $default_languagecode) {
  return "NONE";
}
else {
  return $languagecode;
}


helper function to ge it from settings

function getLanguagePrefix() {
    if($prefixes = \Drupal::config('language.negotiation')-&gt;get('url.prefixes')) {
      $language = \Drupal::languageManager()-&gt;getCurrentLanguage()-&gt;getId();
      return "/". $prefixes[$language];
    }
    return null;
  }