pysepal.solara.locale.match_offered_locale#

pysepal.solara.locale.match_offered_locale(candidate, offered)[source]#

Return the code from offered that best matches candidate.

Order: exact match, bare primary subtag if offered, then the first offered variant sharing the primary subtag. navigator.language reports es-CL where an app ships es, and a catalog may ship pt-BR where the browser reports pt; both must resolve rather than fall through to English.

Parameters:
  • candidate (str) – The code to match, in IETF BCP 47.

  • offered (Iterable[str]) – The codes to match against, in preference order.

Returns:

The matching code, or "" so callers can try their next source.

Return type:

str