elixir - How can I generate gettext translations for ecto model field names? -
i have usual ecto.model
, need register fields translations move them .pot
file. how can that?
update
i'm using these field names prepare list of translated errors:
errors = changeset |> ecto.changeset.traverse_errors(fn {msg, opts} -> enum.reduce(opts, msg, fn {key, value}, _ -> string.replace(msg, "%{#{key}}", to_string(value)) end) end) formatted = {field, messages} <- errors, message <- messages, do: "#{field} #{translate_error(message)}" # functionality here defp translate_error(msgid) gettext.dgettext(myapp.gettext, "errors", msgid) end
i want translate not message, field too!
Comments
Post a Comment