Send emails i18n'd using backend-stored user language
This commit is contained in:
parent
af82f09ce3
commit
0149ea4538
11 changed files with 1760 additions and 273 deletions
|
|
@ -34,4 +34,26 @@ defmodule Pleroma.Web.Gettext do
|
|||
Gettext.get_locale()
|
||||
|> String.replace("_", "-", global: true)
|
||||
end
|
||||
|
||||
def supports_locale?(locale) do
|
||||
Pleroma.Web.Gettext
|
||||
|> Gettext.known_locales()
|
||||
|> Enum.member?(locale)
|
||||
end
|
||||
|
||||
def locale_or_default(locale) do
|
||||
if supports_locale?(locale) do
|
||||
locale
|
||||
else
|
||||
Gettext.get_locale()
|
||||
end
|
||||
end
|
||||
|
||||
defmacro with_locale_or_default(locale, do: fun) do
|
||||
quote do
|
||||
Gettext.with_locale(Pleroma.Web.Gettext.locale_or_default(unquote(locale)), fn ->
|
||||
unquote(fun)
|
||||
end)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@ defmodule Pleroma.Web.Plugs.SetLocalePlug do
|
|||
end
|
||||
|
||||
defp supported_locale?(locale) do
|
||||
Pleroma.Web.Gettext
|
||||
|> Gettext.known_locales()
|
||||
|> Enum.member?(locale)
|
||||
Pleroma.Web.Gettext.supports_locale?(locale)
|
||||
end
|
||||
|
||||
defp parse_language_option(string) do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue