translecto v0.3.3 Translecto.Schema.Translatable
Reference a translatable field in the schema.
This module coincides with the migration function Translecto.Migration.translate/2
. To correctly use this module a schema should call use Translecto.Schema.Translatable
.
Model's with translatable fields can be introspected by using the get_translation/1
and translations/0
functions added to the model. See your model's documentation for additional information.
Link to this section Summary
Functions
Expose a field as being translatable to the schema
Link to this section Functions
Expose a field as being translatable to the schema.
The name of the field specified should coincide with a migration table field that was made using Translecto.Migration.translate/2
.
The queryable should be the translation module (schema) that represents the translation table.
defmodule Ingredient do
use Translecto.Schema.Translatable
schema "ingredients" do
translatable :name, Ingredient.Translation
end
def changeset(struct, params \\ %{}) do
struct
|> translatable_changeset(params, [:name])
|> validate_required([:name])
end
end