Fix and improve language handling
- Refactor plugs to detect and set language - Translate ecto validation errors - Use Gettext directly, not Mobilizon.Web.Gettext - Set the language in the <html> attribute according to the one loaded on front-end Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
@@ -5,15 +5,6 @@ defmodule Mobilizon.Web.ErrorHelpers do
|
||||
|
||||
use Phoenix.HTML
|
||||
|
||||
@doc """
|
||||
Generates tag for inlined form input errors.
|
||||
"""
|
||||
def error_tag(form, field) do
|
||||
Enum.map(Keyword.get_values(form.errors, field), fn error ->
|
||||
content_tag(:span, translate_error(error), class: "help-block")
|
||||
end)
|
||||
end
|
||||
|
||||
@doc """
|
||||
Translates an error message using gettext.
|
||||
"""
|
||||
@@ -31,6 +22,7 @@ defmodule Mobilizon.Web.ErrorHelpers do
|
||||
# dngettext "errors", "1 file", "%{count} files", count
|
||||
# dgettext "errors", "is invalid"
|
||||
#
|
||||
|
||||
if count = opts[:count] do
|
||||
Gettext.dngettext(Mobilizon.Web.Gettext, "errors", msg, msg, count, opts)
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user