PhoenixAssets.Localize (PhoenixAssets v0.1.0)

View Source

Integration plugin that generates the locale contract for the frontend.

Emits locales.ts -- the Locale union, the locales tuple, and defaultLocale -- from either an explicit locales: list or, by default, the subdirectories of priv/gettext (override the scan root with gettext_dir: for umbrella or non-standard layouts), replacing a separate script that scans gettext directories and writes frontend locale data.

defaultLocale resolves in order: the default_locale: option, the configured Gettext backend's default, then the first locale alphabetically. Declare one of the first two when the backend default is not the alphabetically-first locale -- with locales de and en, the bare fallback picks de.

Configuring without a preset

Every option here is also a :stack key, so a host that only wants to pin its market locales does not need to write a preset module:

config :phoenix_assets, :stack,
  locales: ["sv", "en", "no", "da"],
  default_locale: "sv",
  gettext_backend: MyAppWeb.Gettext

A preset's integration/2 options win over the :stack config, so a preset can still override per-app defaults.

Summary

Functions

dev_processes(_, _)

Callback implementation for PhoenixAssets.Plugin.dev_processes/2.

doctor_checks(_, _)

Callback implementation for PhoenixAssets.Plugin.doctor_checks/2.

name()

Callback implementation for PhoenixAssets.Plugin.name/0.

vite_config(_, _)

Callback implementation for PhoenixAssets.Plugin.vite_config/2.