How to set the locale in Phoenix to use priv / gettext / {lang} /LC_MESSAGES/errors.po?
As a test, I built a locale file using mix gettext.merge priv/gettext --locale ja and translated a few words into it.
It works if I explicitly call put_locale/2 in web/views/error_helpers.ex and <%= translate_error(message) %> in the template file, but it is a little ugly at the DRY point.
def translate_error(msg) do Gettext.put_locale(LoginStudy.Gettext, "ja") Gettext.dgettext(LoginStudy.Gettext, "errors", msg) end
Is there a better way to set the default locale? I have specified default_locale in config/config.ex , but it does not work.
config :login_study, LoginStudy.Endpoint, default_locale: "ja",
Best wishes,
source share