style: translate fieldtypes and payment as button
This commit is contained in:
parent
702eebd110
commit
94de429529
3 changed files with 48 additions and 22 deletions
21
lib/mv_web/translations/field_types.ex
Normal file
21
lib/mv_web/translations/field_types.ex
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
defmodule MvWeb.Translations.FieldTypes do
|
||||
@moduledoc """
|
||||
Helper module to dynamically translate field types.
|
||||
|
||||
## Features
|
||||
- Can be used in templates to dynamically translate technical field type words to human friendly text
|
||||
|
||||
## Example
|
||||
assigns = assign(assigns, :field_type_label, &MvWeb.Translations.FieldTypes.label/1)
|
||||
In template:
|
||||
<%= @field_type_label.(custom_field.value_type) %>
|
||||
"""
|
||||
use Gettext, backend: MvWeb.Gettext
|
||||
|
||||
@spec label(atom()) :: String.t()
|
||||
def label(:string), do: gettext("Text")
|
||||
def label(:integer), do: gettext("Number")
|
||||
def label(:boolean), do: gettext("Yes/No-Selection")
|
||||
def label(:date), do: gettext("Date")
|
||||
def label(:email), do: gettext("E-Mail")
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue