This gist was extracted from a Phoenix LiveView project where I needed to support multiple languages. Translations are managed using GetText and the standard commands available in projects generated with Phoenix 1.7.
The code in this gist demonstrates how to use a Plug to store the locale in the session and a LiveView on_mount hook to set the current locale in LiveView assigns.
The Plug integrates with the rest of the project through a router pipeline, and the on_mount hook is attached to every LiveView by updating the generated ...Web
module.