An Ecto.Type storing a locale as its BCP 47 string in a text column.
A Localize.LanguageTag.t/0 is a rich struct — resolved likely
subtags, -u- extension keywords, a canonical form — but all of it is
derived from the language tag string, so the string is what is stored.
The column is ordinary text holding a canonical tag such as "en-US"
or "de-DE-u-co-phonebk".
Values load back into a fully resolved Localize.LanguageTag.t/0 via
Localize.validate_locale/1, so a loaded locale is canonicalized, has
its -u- extensions populated and its likely subtags resolved — the
same value Localize.validate_locale/1 returns anywhere else, and the
resolution is cached.
Schema
# in a migration
add :locale, :string
# in a schema
field :locale, Localize.LanguageTag.Ecto.TypeCasting
cast/1 accepts a Localize.LanguageTag.t/0, or any locale
identifier Localize.validate_locale/1 accepts — a string ("en-US")
or an atom (:"en-US"). An identifier that is not a valid locale
returns an error rather than being stored.
Summary
Functions
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.
Functions
Callback implementation for Ecto.Type.embed_as/1.
Callback implementation for Ecto.Type.equal?/2.