AcceptLanguage

parses Accept-Language headers and performs server-side language negotiation, matching ranges against tags by RFC 4647 §3.3.1 basic filtering.

negotiate

defn

(Fn [(Ref String a), (Ref (Array String) b)] (Maybe String))

                        (negotiate accept offers)
                    

selects the best language tag to serve from offers given an Accept-Language header value, as (Maybe String). Ranges match tags by RFC 4647 §3.3.1 basic filtering: * matches anything, and a range matches a tag it prefixes on a subtag boundary, so en matches en-US but neither en-US matches en nor en matches eng. Each offer takes the weight of the most specific range matching it; a weight of 0 (or no matching range) makes the offer unacceptable. The highest-weighted acceptable offer wins, ties broken by range specificity and then by the order of offers; matching is case-insensitive. An empty Accept-Language accepts anything and yields the first offer; Nothing means nothing is acceptable.

parse

defn

(Fn [(Ref String a)] (Array Weighted))

                        (parse s)
                    

parses an Accept-Language header value into its weighted language ranges, in header order.