2020-06-18 15:23:05 +02:00
|
|
|
defmodule Mobilizon.Web.Views.Utils do
|
|
|
|
@moduledoc """
|
|
|
|
Utils for views
|
|
|
|
"""
|
|
|
|
|
2021-07-21 15:46:04 +02:00
|
|
|
@spec get_locale(Plug.Conn.t()) :: String.t()
|
|
|
|
def get_locale(%Plug.Conn{assigns: assigns}) do
|
2021-07-27 19:47:54 +02:00
|
|
|
Map.get(assigns, :locale)
|
2021-07-21 15:46:04 +02:00
|
|
|
end
|
2021-11-07 21:02:06 +01:00
|
|
|
|
|
|
|
@ltr_languages ["ar", "ae", "he", "fa", "ku", "ur"]
|
|
|
|
|
|
|
|
@spec get_language_direction(String.t()) :: String.t()
|
2022-07-12 10:55:28 +02:00
|
|
|
def get_language_direction(locale) when locale in @ltr_languages, do: "rtl"
|
|
|
|
def get_language_direction(_locale), do: "ltr"
|
2020-06-18 15:23:05 +02:00
|
|
|
end
|