Downloads locale ETF files from the Localize CDN and stores them in the configured locale cache directory.
This task is intended to be run at build time (e.g. in a Dockerfile or CI pipeline) so that all required locales are available in the cache before the application starts. This avoids the need for runtime downloads in production.
Usage
mix localize.download_localesDownloads the configured :supported_locales. When
:supported_locales is not configured (meaning all CLDR
locales are supported), prompts for confirmation before
downloading.
mix localize.download_locales en fr de jaDownloads the specified locales.
mix localize.download_locales --allDownloads all CLDR locales without prompting.
mix localize.download_locales --force--force does two things: (1) when :supported_locales is not
configured, it downloads all locales without prompting (useful in
CI/Docker where there is no interactive terminal); and (2) it
re-downloads every requested locale even if a current copy already
exists in the configured cache directory, bypassing the
"already current" skip.
Output directory
Files are written to the directory returned by
Localize.Locale.Provider.locale_cache_dir/0, which defaults
to Application.app_dir(:localize, "priv/localize/locales").
Override with:
config :localize, locale_cache_dir: "/path/to/cache"Skip behaviour
A locale is reported (current) and skipped only when a
version-matching copy already exists in the configured cache
directory — the same directory the task writes to. The bundled
fallback directory inside the :localize dependency
(Application.app_dir(:localize, …)) is deliberately not
consulted for this decision, so a copy shipped with the dependency
never prevents the task from populating your configured directory.
Use --force to re-download regardless of the current copy.
Compile-time configuration
The task only loads compile-time configuration (config/config.exs and any
imported env-specific files) and never evaluates config/runtime.exs. This
makes it safe to run inside "build-only" environments (such as Docker images)
where production-only environment variables are deliberately not available.
The task itself reads only :localize's own compile-time config.
Examples
Pre-populate the cache for a Docker build:
# Dockerfile
RUN mix localize.download_localesDownload specific locales for testing:
mix localize.download_locales en de ja zhDownload everything in a non-interactive environment:
mix localize.download_locales --force