mix localize.download_inflection (Localize v1.4.0)

Copy Markdown View Source

Downloads inflection data files from the Localize CDN into the configured inflection data directory.

Inflection data is optional: nothing is downloaded unless this task runs, and inflection functions return {:error, %Localize.InflectionDataNotAvailableError{}} for a locale whose data is absent. Run the task at build time (a Dockerfile or CI pipeline), like mix localize.download_locales.

Usage

mix localize.download_inflection

Downloads the configured :supported_locales (intersected with the languages the inflection data covers).

mix localize.download_inflection en fr de ru

Downloads the specified locales.

mix localize.download_inflection --all

Downloads every inflection-supported language.

mix localize.download_inflection --force

Re-downloads files that already exist in the data directory.

mix localize.download_inflection --prune

Removes the directories of superseded data versions once the current version has downloaded.

Output directory

Files are written to Localize.Inflection.DataDir.dir/0; see that module for the :otp_app / :inflection_data_dir configuration forms.

That directory carries the data version, so each version holds its own artifacts and a file of an earlier version is never read in place of a current one. The directories of superseded versions survive an upgrade; the task names them when it finds them, and --prune removes them.

Every download is verified against the SHA-256 manifest shipped in the package before it is written.

Summary

Functions

Downloads inflection data for the inflection-supported languages among locale_names.

Functions

download_for(locale_names, force? \\ false)

Downloads inflection data for the inflection-supported languages among locale_names.

Accepts locale identifiers in any form; regional locales map to their parent language (en-AU → en) and locales the inflection project does not support are skipped. Shared with mix localize.download_locales, which downloads inflection data alongside the locale data so one command provisions both.

Arguments

  • locale_names is a list of locale identifiers.

  • force? downloads files already present when true. The default is false.

Returns

  • The number of failed downloads, 0 when every download succeeded.

Examples

A locale the inflection project does not support is skipped, so nothing is downloaded:

iex> Mix.Tasks.Localize.DownloadInflection.download_for(["zz"])
0