Skip to main content

build

Function build 

Source
pub fn build(
    locales: &[Locale],
    url_prefix: &str,
    url_path: &str,
    mode: LocaleMode,
    current_code: Option<&str>,
) -> Vec<SwitcherEntry>
Expand description

Build switcher entries for url_path across the given active locales. The URL shape follows mode:

  • default locale → {url_prefix}{url_path}?lang={code} (explicit so a click resets the persistence cookie — see locale_mode::LOCALE_COOKIE),
  • path modes → {url_prefix}/{code}{url_path},
  • query mode → {url_prefix}{url_path}?lang={code}.

current_code is the locale the request resolved to (None = the default); the matching entry is flagged is_current.