resolveLanguage
Picks the language to show. A choice the host offers wins. Otherwise the
first of browserLanguages, in the browser's own order, that the host
offers: an exact tag match, or failing that an offered tag with the same
language subtag (so a browser's "af-ZA" gets an offered "af", and
"en-ZA" gets an offered "en-GB"). Failing all of those, fallback.
This is a function exported by @mapcairn/core, checked against version 0.2.0.
Signature
import { resolveLanguage } from "@mapcairn/core";
function resolveLanguage(choice: string | null, offered: readonly string[], browserLanguages: readonly string[], fallback: string): string;
Parameters
choice(string | null): The person's stored choice, ornullto follow the browser.offered(readonly string[]): The tags the host offers.browserLanguages(readonly string[]): The browser's languages, most preferred first.fallback(string): The host's default language, returned when nothing matches.
Returns
string: A tag from offered, or fallback.