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