I18n Helpers v0.5.1 I18nHelpers.Ecto.Translator View Source
Link to this section Summary
Functions
Returns a closure allowing to memorize the given options for translate\3
.
Translates an Ecto struct, a list of Ecto structs or a map containing translations.
Link to this section Functions
Returns a closure allowing to memorize the given options for translate\3
.
translate(data_structure, locale \\ Gettext.get_locale(), opts \\ [])
View SourceTranslates an Ecto struct, a list of Ecto structs or a map containing translations.
Translating an Ecto struct for a given locale consists of the following steps:
Get the list of the fields that need to be translated from the Schema. The Schema must contain a
get_translatable_fields\0
function returning a list of those fields.Get the text for the given locale and store it into a virtual field. The Schema must provide, for each translatable field, a corresponding virtual field in order to store the translation.
Get the list of the associations that also need to be translated from the Schema. The Schema must contain a
get_translatable_assocs\0
function returning a list of those associations.Repeat step 1. for each associated Ecto struct.