style: translate fieldtypes and payment as button

This commit is contained in:
carla 2025-12-03 22:18:18 +01:00
parent 702eebd110
commit 94de429529
3 changed files with 48 additions and 22 deletions

View 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