More bidi improvements

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel
2021-11-07 21:02:06 +01:00
parent 7a30c92651
commit 7c4a76cc89
48 changed files with 127 additions and 113 deletions

View File

@@ -49,11 +49,20 @@ defmodule Mobilizon.Web.Views.Utils do
defp do_replacements(index_content, tags, locale) do
index_content
|> replace_meta(tags)
|> String.replace("<html lang=\"en\">", "<html lang=\"#{locale}\">")
|> String.replace(
"<html lang=\"en\" dir=\"auto\">",
"<html lang=\"#{locale}\" dir=\"#{get_language_direction(locale)}\">"
)
end
@spec get_locale(Plug.Conn.t()) :: String.t()
def get_locale(%Plug.Conn{assigns: assigns}) do
Map.get(assigns, :locale)
end
@ltr_languages ["ar", "ae", "he", "fa", "ku", "ur"]
@spec get_language_direction(String.t()) :: String.t()
defp get_language_direction(locale) when locale in @ltr_languages, do: "rtl"
defp get_language_direction(_locale), do: "ltr"
end