<our-lang-switcher>
<our-lang-switcher> renders a link for each language that has a culture domain set up in Umbraco, to build a language switcher. You choose the markup by writing a Mustache template inside the element.
With your own template
Section titled “With your own template”<our-lang-switcher> <div class="lang-switcher"> {{#Languages}} <div class="lang-switcher__item"> <a href="{{Url}}" lang="{{Culture}}" hreflang="{{Culture}}" class="lang-switcher__link {{#IsCurrentLang}}selected{{/IsCurrentLang}}">{{Name}}</a> </div> {{/Languages}} </div></our-lang-switcher>On a site with English and Danish, that renders:
<div class="lang-switcher"> <div class="lang-switcher__item"> <a href="https://localhost:44331/en" lang="en-US" hreflang="en-US" class="lang-switcher__link selected">English</a> </div> <div class="lang-switcher__item"> <a href="https://localhost:44331/dk" lang="da-DK" hreflang="da-DK" class="lang-switcher__link ">dansk</a> </div></div>Template values
Section titled “Template values”Inside {{#Languages}} … {{/Languages}}, each language has:
| Value | What it is |
|---|---|
{{Url}} |
The language’s domain, as set in Culture and Hostnames. |
{{Culture}} |
The culture code, such as en-US. |
{{Name}} |
The language’s name in that language, such as English or dansk. |
{{#IsCurrentLang}} … {{/IsCurrentLang}} |
Renders its content only for the current page’s language. |
The default template
Section titled “The default template”<our-lang-switcher /> with nothing inside uses this template:
<ul class='lang-switcher'> {{#Languages}} <li> <a href='{{Url}}' lang='{{Culture}}' hreflang='{{Culture}}' class='{{#IsCurrentLang}}selected{{/IsCurrentLang}}'> {{Name}} </a> </li> {{/Languages}}</ul>