All notable changes to this project will be documented in this file. This project adheres to Semantic Versioning.
Localize.HTML.Subdivisiongenerates<select>tags and option lists for the subdivisions of a territory — US states, Canadian provinces, French departments — localized and sorted withLocalize.Collation. CLDR writes a subdivision code as its territory plus the ISO 3166-2 code, so:uscabecomes an option value of"ca"; passfull_codes: trueto keep the CLDR form.
-
Localize.HTML.Currency.select/3,Localize.HTML.Locale.select/3,Localize.HTML.Territory.select/3andLocalize.Plug.put_locale_from_session/2are specified as returning{:error, Exception.t()}. Each reports an invalid locale as an exception struct rather than the{module, message}tuple its specification claimed — the same correction made toLocalize.HTML.Unit.select/3in 1.0.0, which the others were missed in. -
Localize.HTML.Month.select/3andmonth_options/1now validate the:localeoption, returning{:error, Exception.t()}as every other select does. They previously ignored an invalid locale and rendered month names in the default one, so a typo produced English months rather than an error.
-
~qnow resolves the#{locale},#{language}and#{territory}interpolation forms, which previously raiseda dynamic ~p interpolation must follow a static segmentat compile time in every position. Substituting the token left the enclosing::binarywrapper in place, so Phoenix saw a literal inside a dynamic segment and matched none of its route-verification clauses. Thanks to @sumerokr for the report. Closes #15. -
mix phx.routes <Router>.LocalizedRoutesnow works, where it raisedfunction ... formatted_routes/1 is undefined. The generated module hosts route definitions but is not a router, so theformatted_routes/1and__helpers__/0callbacksPhoenix.Router.ConsoleFormattercalls are now defined on it. Thanks to @sumerokr for the report. Closes #16.
-
Align the documentation module names to the canonical Phoenix generator forms, and require
~> 1.0in the installation snippets rather than the long-superseded~> 0.1.0. Thanks to @sumerokr for the PRs. Closes #13, #14. -
Localize.VerifiedRoutesdocuments that every option other than:gettextpasses through toPhoenix.VerifiedRoutes, and that:staticsin particular must be kept when converting fromuse Phoenix.VerifiedRoutes— without it the asset paths in the default Phoenix layouts warn that no route matches (#16).
- The
LocalizeWebmodule. It defined no functions — only a moduledoc listing the plugs, routes and HTML helpers, all of which live underLocalize.*and are unaffected.
The first stable release, built on Localize 1.0.
- Requires
localize ~> 1.0.
-
Localize.HTML.Unit.select/3is specified as returning{:error, Exception.t()}. Localize 1.0 reports an invalid unit or locale as an exception struct rather than a{module, message}tuple, so the previous specification did not describe what the function returns. -
currency_options/1,locale_options/1,territory_options/1andunit_options/1no longer claim to return an error tuple. They validate by raising, so the documented error return could not occur.
Localize.Plug.PutSessionno longer rewrites the session (and emits a redundantSet-Cookie) when the stored locale is unchanged, avoiding needless response bandwidth and preventing caching layers from treating responses as private. Ported fromex_cldr_plugswith thanks @maltoe.
-
Localize.HTML.Message— new function component (andLocalize.HTML.message/1facade) that renders an MF2 message preserving inline markup. Thelinkdefault renderer uses Phoenix's<.link>and so acceptshref,navigate, orpatchMF2 attributes; per-call:componentsandconfig :localize_web, :mf2_markup, components: %{…}override the defaults, and unknown tags raiseLocalize.HTML.Message.UnknownMarkupError. -
Localize.HTML.t/1andt/2— new compile-time macros for HEEx templates that combine Gettext extraction, MF2 binding interpolation, and markup rendering in one call:{t("Read {#bold}terms{/bold}")}. Elixir#{@user.name}interpolations have theassignsprefix stripped so derived binding names match what a developer would write (@user.name→user_name).
mix testnow runsmix localize.download_localesfirst, populating CLDR data for the locales referenced by the suite (en,fr,de,th,ja,ar,zh,zh-Hans,zh-Hant). Fresh checkouts and CI no longer fail on missing locale display data.
- Add
path_for/2andurl_for/2macros toLocalize.VerifiedRoutesto render a verified path or URL in an explicit locale without changing the process-wide locale, supporting language-switcher and hreflang use cases that need every configured locale rendered in one template pass.
-
Ignore out-of-range and zero-weight q-values when parsing
accept-languageheaders per RFC 9110. Thanks to @rubas for the PR. Closes #6. -
Expose
month_select/3andmonth_options/1on theLocalize.HTMLfacade as documented in the moduledoc. Thanks to @rubas for the PR. Closes #9. -
Honor the
:calendaroption inLocalize.HTML.Monthby sourcing month labels from the CLDR calendar returned by the calendar module'scldr_calendar_type/0function. Thanks to @rubas for the PR. Closes #10.
- Document that
fetch_session/1must run beforeLocalize.Plug.PutLocalewhen:sessionor:cookiesources are used. Thanks to @rubas for the PR. Closes #7.
- Be more lenient when parsing invalid
accept-languageheaders. Duplicateq=might be invalid syntax but they shouldn't crash the parser. Thanks to @woylie for the report. Closes #3.
- Don't call
Localize.default_locale/0at compile time. That causeslocalizeto be loaded at compile time which causes issues on machines with constrained resources. Defer the call to runtime.
- Make
phoenix_html_helpersa required dependency (it was optional).
- Fix docs links in the package.
Initial release of localize_web, providing Phoenix integration for the Localize library. This library consolidates the functionality previously provided by ex_cldr_plugs, ex_cldr_routes, and cldr_html into a single package.
-
Locale discovery plugs that detect the user's locale from the accept-language header, query parameters, URL path, session, cookies, hostname TLD, or custom functions. Includes session persistence and LiveView support.
-
Compile-time route localization that translates route path segments using Gettext, generating localized routes for each configured locale. Supports locale interpolation, nested resources, and all standard Phoenix route macros.
-
Verified localized routes via the
~qsigil, providing compile-time verification of localized paths that dispatch to the correct translation based on the current locale. -
Localized HTML form helpers that generate
<select>tags and option lists for currencies, territories, locales, units of measure, and months with localized display names.
See the README for full documentation and usage examples.