View Source Routex.Extension.Cldr (Phoenix Routes Extension Framework v0.3.0-alpha.3)
Adapter for projects using :ex_cldr. It generates the configuration
for Routex.Extension.Alternatives
.
Interpolating Locale Data
Interpolation is provided by Routex.Extension.
Interpolation, which is able to use any
Routex.Attrfor interpolation. See it's documentation for additional options. When using this Cldr extension, the following interpolations are supported as they are set as
Routex.Attr: *
localewill interpolate the Cldr locale name *
locale_displaywill interpolate the Cldr locale display name *
languagewill interpolate the Cldr language name *
territorywill interpolate the Cldr territory code Some examples are: ```elixir preprocess_using ExampleWeb.RoutexBackend do scope "/#{territory}/territory/" do get "/#{locale}/locale/pages/:page", PageController, :show get "/language/#{language}/pages/:page", PageController, :show end end ``` ## Configuration ```diff defmodule ExampleWeb.RoutexBackend do use Routex.Backend, extensions: [ + Routex.Extension.Cldr, + Routex.Extension.Alternatives, + Routex.Extension.Interpolation, # when using routes with interpolation + Routex.Extension.Translations, # when using translated routes + Routex.Extension.VerifiedRoutes, [...] Routex.Extension.AttrGetters ], + cldr_backend: MyApp.Cldr, + translations_backend: MyApp.Gettext, # when using translated routes + translations_domain: "routes", # when using translated routes + alternatives_prefix: false, # when using routes with interpolation + verified_sigil_routex: "~q", # consider using ~p, see
Routex.Extension.VerifiedRoutes``` ```diff defmodule ExampleWeb.Router # require your Cldr backend module before
useing the router. + require ExampleWeb.Cldr use ExampleWeb, :router import ExampleWeb.UserAuth ``` ## Pseudo result This extension injects
:alternativesinto your configuration. See the documentation of
Routex.Extension.Alternativesto see more options and the pseudo result. ``` alternatives: %{ "/" => %{ attrs: %{ language: "en", locale: "en", territory: "US", locale_display: "English (United States)" }, branches: %{ "/en" => %{ language: "en", locale: "en", territory: "US", locale_dispay: "English" }, "/fr" => %{ language: "fr", locale: "fr", territory: "FR", locale_display: "français" } } } ``` ##
Routex.Attrs`
Requires
- none
Sets
- language
- locale
- locale_display
- territory
Summary
Functions
Callback implementation for Routex.Extension.configure/2
.
Functions
Callback implementation for Routex.Extension.configure/2
.