While Drupal ships a default language switcher block, its options are very limited by default and are not easily customizable without using hooks or complicated template overrides.
The Language Switcher Extended module
To solve this problem, the Language Switcher Extended module has been created. Thanks to this module, some new options are available through its config tab once it its installed on your site.
Display languages codes instead of full languages names
It is a common need to want to display the 2 letters langcodes (ISO 639-1) instead of their full names to simplify the language switcher display and the reduce its footprint on the screen.
To achieve this, go to the module configuration page /admin/config/regional/language/language-switcher-extended
and tick the Show langauge code
box.
Now, languages will be displayed in their ISO 639-1 format wherever the language selector block is placed.
Disable the current language link
A more subtle change than the previous one but still worthwhile, it is also possible to disable the link for the current selected language. As before, go to the module configuration page /admin/config/regional/language/language-switcher-extended
, then chose the Display the language without link option from the Current language mode field.
Redirect to the homepage when no translated content is available
To finish, it is also possible to change the language selector language behavior when no translated content is available. Again, go to /admin/config/regional/language/language-switcher-extended
and select the Link to the frontpage option from the Untranslated Handler field to redirect any non-translated languages to the frontpage.