View Source EctoI18n.Schema (ecto_i18n v0.4.1)
Provides i18n extensions for Ecto.Schema
.
Summary
Functions
Creates a virtual field and an embed for storing localized data.
Functions
Creates a virtual field and an embed for storing localized data.
Example
defmodule MyApp.Shop.Product do
use Ecto.Schema
use EctoI18n.Schema, locales: ["en", "zh-Hans"]
schema "products" do
field :sku, :string
field_i18n :name, :string
end
end
In above code, calling:
field_i18n :name, :string
equals to:
field :name, :string, virtual: true
embeds_one :name_i18n, NameI18n do
field :"en", :string
field :"zh-Hans", :string
end
The NameI18n
module will be generated automatically.