pub fn negotiate_locale(
preferred: &[String],
available: &[String],
default_locale: &str,
) -> StringExpand 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:
- Exact match (e.g., “fr-CH” matches “fr-CH”)
- Prefix match (e.g., “fr-CH” matches “fr”)
- Default locale fallback
§Examples
use ssg_i18n::negotiate_locale;
let pref = vec!["fr-CH".to_string(), "en".to_string()];
let avail = vec!["en".to_string(), "fr".to_string()];
assert_eq!(negotiate_locale(&pref, &avail, "en"), "fr");