Ah sorry, In fact I didn’t test the method that generates a pot file when setting up the package…
But what I do is injecting the auth app messages in some module that must be provided to the auth app config. Please see below a sample of my auth backend messages definition:
defmodule MyAuth.Messages do
@moduledoc """
Module that handles messages.
## Usage
defmodule MyApp.Auth.Messages do
use MyAuth.Messages, [gettext: MyApp.Gettext]
end
Remember to add `messages_backend: MyApp.Auth.Messages` to your
configuration.
"""
defmacro __using__([gettext: backend] = _opts) do
quote do
use Pow.Phoenix.Messages
use Pow.Extension.Phoenix.Messages,
extensions: [PowResetPassword, PowEmailConfirmation, PowInvitation]
# import Gettext backend
import unquote(backend)
# Override pow messages here
def user_not_authenticated(_conn),
do: dgettext("auth", "You need to sign in to access this page.")
def signed_in(_conn), do: dgettext("auth", "You have been logged in.")
def signed_out(_conn), do: dgettext("auth", "You have been logged out.")
def user_could_not_be_deleted(_conn),
do: dgettext("auth", "Your account could not be deleted.")
def auth_unauthorized_access(_conn),
do: dgettext("auth", "You are not authorized to access the requested page.")
end
end
end
In my case I just write some auth library on top of Pow auth package so that i can reuse it my projects. Basically The Pow app will fetch in its config the messages_backend
which is defined in the Phoenix app, to display specific messages. So in my projects I just define this module which need of course the phoenix app gettext backend to work as expected:
defmodule MyApp.Auth.Messages do
use MyAuth.Messages, [gettext: MyApp.Gettext]
end
Then I added to my Pow config:
# Pow config
config :my_app, :pow,
messages_backend: MyApp.Auth.Messages
Next step when I run gettext extract --merge
task from my_app
root the auth
translations files are generated according to my_app
gettext config. In some new projects I follow almost the same steps but I can just copey and paste translations files that already exist.
I hope this will be helpful to you.