Problem with translations (gettext)

I have a problem with some of translations which are not applied. As an example of such translations is the module like this:

defmodule JpWeb.SpecialistDefinitions do
  import JpWeb.Gettext

  @specialists_search_definition %{
    schema: Jp.Profiles.Specialist,
    filters: [

      %{
        field: :is_verified,
        operation: "==",
        options: [{"Yes", true}, {"No", false}],
        label: gettext("Is verified")
      },

      %{
        field: :photo,
        operation: "is_present",
        label: gettext("With photo")
      },
    ]
  }

  def specialist_definition, do: @specialists_search_definition
end

Translations located in .eex templates files are applied.

What may cause such behaviour?

1 Like

With the @ syntax you’re defining a module attribute.
Those are set at compile time. This means your gettext function is evaluated only once, when when you compile you code.

4 Likes

Thanks, @wmnnd I replaced the @specialists_search_definition to
def specialists_search_definition, do:
and everything worked.

1 Like