mix lang_tags.update (lang_tags v0.2.0)

Copy Markdown View Source

Fetches the current IANA language subtag registry and writes it to priv/language-subtag-registry.

$ mix lang_tags.update

The registry is compiled into pattern-matched function heads at build time, so a recompile is required for the new data to take effect:

$ mix lang_tags.update
$ mix compile --force

Options

  • --check - report whether a newer registry is available without writing anything. Exits with a non-zero status when an update is available, which makes it usable as a scheduled CI check.

Summary

Functions

Reads the File-Date header of a registry file on disk.

Extracts the File-Date header from registry contents.

Checks that contents look like the IANA registry before we overwrite the bundled copy with them.

Functions

file_date(path)

@spec file_date(Path.t()) :: {:ok, binary()} | :error

Reads the File-Date header of a registry file on disk.

Only the first line is read. The registry is several hundred kilobytes and the header is its first line, so there is no reason to load the rest of it just to compare dates.

parse_file_date(arg1)

@spec parse_file_date(binary()) :: {:ok, binary()} | :error

Extracts the File-Date header from registry contents.

The header is only recognised on the first line, which is where the record-jar format requires it.

validate_registry(contents)

@spec validate_registry(binary()) :: :ok | {:error, binary()}

Checks that contents look like the IANA registry before we overwrite the bundled copy with them.