Skip to main content

negotiate_locale

Function negotiate_locale 

Source
pub fn negotiate_locale(
    preferred: &[String],
    available: &[String],
    default_locale: &str,
) -> String
Expand description

Given a list of preferred locales (from Accept-Language) and a list of available locales (directories on disk), returns the best match.

Matching rules:

  1. Exact match (e.g., “fr-CH” matches “fr-CH”)
  2. Prefix match (e.g., “fr-CH” matches “fr”)
  3. Default locale fallback