riverrun / phauxth

Not actively maintained - Authentication library for Phoenix, and other Plug-based, web applications
409 stars 20 forks source link

Allow to translate strings via GetText #43

Closed clementoriol closed 6 years ago

clementoriol commented 6 years ago

Hello, First of all, thank you for working on phauxth, I'm really enjoying using it !

The library still has some hardcoded (english) strings in some places, like in https://github.com/riverrun/phauxth/blob/master/lib/phauxth/confirm/report.ex .

While this is not an issue for logs, some of theses messages appears for the end-user, so it needs to be translated in some way.

A nice developper experience would be to allow the library user to translate those string from its app .po files, like any other string. Being able to use the gettext mix tasks like mix gettext.extract would be a plus.

I could help with this, but I'm not sure how you'd want to approach this.

The Coherence library, for exemple, does this by implementing a Messages behavior (https://github.com/smpallen99/coherence/blob/bcff8bc6276596496e66da3376c8a8da2fe4c185/lib/coherence/messages.ex) that's implemented from the user app side (https://github.com/smpallen99/coherence/blob/bcff8bc6276596496e66da3376c8a8da2fe4c185/priv/templates/coh.install/coherence_messages.ex).

riverrun commented 6 years ago

Thanks for raising this issue. I will look into it next week some time.

riverrun commented 6 years ago

I have added a UserMessages module (in commits 191 and 192). It's similar to the coherence idea of moving the responsibility for the translations to the web app.

The default user_messages module can be changed in the config, and this can allow developers to create custom messages and / or use gettext to provide translations.

If you have any questions / comments, please let me know.