chore: adjust Gettext definition and usage

This commit is contained in:
Joao P Dubas 2024-10-29 23:35:42 +00:00
parent 78e35ded8e
commit 7421c820e5
No known key found for this signature in database
2 changed files with 6 additions and 5 deletions

View file

@ -21,13 +21,14 @@ defmodule LiveBeatsWeb do
def controller do def controller do
quote do quote do
use Gettext, backend: LiveBeatsWeb.Gettext
use Phoenix.Controller, use Phoenix.Controller,
namespace: LiveBeatsWeb, namespace: LiveBeatsWeb,
formats: [:html, :json], formats: [:html, :json],
layouts: [html: LiveBeatsWeb.Layouts] layouts: [html: LiveBeatsWeb.Layouts]
import Plug.Conn import Plug.Conn
import LiveBeatsWeb.Gettext
alias LiveBeatsWeb.Router.Helpers, as: Routes alias LiveBeatsWeb.Router.Helpers, as: Routes
unquote(verified_routes()) unquote(verified_routes())
end end
@ -92,8 +93,8 @@ defmodule LiveBeatsWeb do
def channel do def channel do
quote do quote do
use Gettext, backend: LiveBeatsWeb.Gettext
use Phoenix.Channel use Phoenix.Channel
import LiveBeatsWeb.Gettext
end end
end end
@ -102,10 +103,10 @@ defmodule LiveBeatsWeb do
# Use all HTML functionality (forms, tags, etc) # Use all HTML functionality (forms, tags, etc)
import Phoenix.HTML import Phoenix.HTML
import Phoenix.HTML.Form import Phoenix.HTML.Form
use Gettext, backend: LiveBeatsWeb.Gettext
use PhoenixHTMLHelpers use PhoenixHTMLHelpers
import LiveBeatsWeb.CoreComponents import LiveBeatsWeb.CoreComponents
import LiveBeatsWeb.Gettext
alias LiveBeatsWeb.Router.Helpers, as: Routes alias LiveBeatsWeb.Router.Helpers, as: Routes
alias Phoenix.LiveView.JS alias Phoenix.LiveView.JS
unquote(verified_routes()) unquote(verified_routes())

View file

@ -5,7 +5,7 @@ defmodule LiveBeatsWeb.Gettext do
By using [Gettext](https://hexdocs.pm/gettext), By using [Gettext](https://hexdocs.pm/gettext),
your module gains a set of macros for translations, for example: your module gains a set of macros for translations, for example:
import LiveBeatsWeb.Gettext use Gettext, backend: LiveBeatsWeb.Gettext
# Simple translation # Simple translation
gettext("Here is the string to translate") gettext("Here is the string to translate")
@ -20,5 +20,5 @@ defmodule LiveBeatsWeb.Gettext do
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage. See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
""" """
use Gettext, otp_app: :live_beats use Gettext.Backend, otp_app: :live_beats
end end