Routex.Extension.Localize.Phoenix.Extractor (Routex v1.2.2)

View Source

Extracts locale information from various sources. Handles both Plug.Conn structs and map inputs.

Supports languages and regions defined in the IANA Language Subtag Registry

Sources

List of sources to examine for this field.

  • :accept_language examines the accept-language header.
  • :body uses body_params; useful when using values in API bodies.
  • :cookie uses the request cookie(s)
  • :host examines the hostname e.g en.example.com and example.nl. Returns the first match..
  • :path uses path_params such as /:locale/products/
  • :query uses query_params such as /products?locale=en-US
  • :route uses the (precompiled) route attributes.
  • :session uses the session
  • :assigns uses the assigns stored in connection of socket

Params

List of keys in a source to examine. Defaults to the name of the field with fallback to locale.

Summary

Functions

do_extract_from_source(conn, arg2, param, attrs)

extract_from_source(conn_like, source, param, attrs)

@spec extract_from_source(Plug.Conn.t() | map(), atom(), String.t(), keyword()) ::
  String.t() | nil