icon Language Switcher (Razor)
Created by Orckestra

How to add a Language Switcher to a website

  1. From the Content perspective, insert the Composite.Navigation.LanguageSwitcher function ( Insert > Function) on a page, or from the Layout perspective, add the following code to a template:
      Expand code
  2. In the Mode parameter, select one of the menu modes for switching languages:
    • HomePages: always displays links to the home pages of all localized websites
    • TranslatedPages: only displays links to the current pages in other languages if translated; otherwise, shows no links
    • TranslatedOrHomePages: displays links to the current pages in other languages if translated; otherwise, shows links to the home pages.
  3. Set up other optional parameters:
    • Show Current: Shows the link to the page in the currently selected language ("True", by default). Uncheck the option if you want otherwise.
    • Format: (see below "How to change the language format)
    • Style: One of the following styles to show the switcher:
      • "Inline": All the languages shown inline one by one
      • "Collapsed": A button shown to drop down a menu with the languages when clicked
      • "CollapsedOnSmallScreen": (default) Combined ("Inline" on wide screens and "Collapsed" on small ones)
    • Description: The text will be displayed next to the menu links (blank, by default)
    • IncludeQuery: When 'True', the query parameters (e.g. "MyPage.aspx?Id=a3522d3c-45be-42df-b31f-ea508bc137ba") in the URL will be kept when switched to another language; otherwise ('False'), the query parameters will not be included in the URL (e.g. "MyPage.aspx"). 'True' by default.

How to change the language format

Optionally, you can change the way the language switching menu is presented by setting the Format parameter to one of the following values:
  • DisplayName: Gets the culture name in the format "<languagefull>" in the language of the localized version of .NET Framework.
  • EnglishName: Gets the culture name in the format "<languagefull>" in English.
  • Name: Gets the culture name in the format "<languagecode2>- <country/regioncode2>".
  • NativeName: Gets the culture name, consisting of the language.
  • ThreeLetterISOLanguageName: Gets the ISO 639-2 three-letter code for the language
  • ThreeLetterWindowsLanguageName: Gets the three-letter code for the language as defined in the WindowsPI.
  • TwoLetterISOLanguageName: (default) Gets the ISO 639-1 two-letter code for the language of the current CultureInfo.
  • Image: Gets images representing the languages (flags) - see the Important note below.

Important: To show images (flags) for languages, you also need to install the Composite.Navigation.LanguageSwitcher.Flags package.