-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update generators with new Gettext API #5902
Changes from 1 commit
c2576ef
685c961
12e2cdc
f6eca1c
0a7443a
15bebbb
d117b10
4888131
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,10 @@ defmodule <%= @web_namespace %> do | |
use Phoenix.Controller, | ||
formats: [:html, :json], | ||
layouts: [html: <%= @web_namespace %>.Layouts] | ||
<%= if @gettext do %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will leave trailing whitespace. I think the |
||
use Gettext, backend: <%= @web_namespace %>.Gettext<% end %> | ||
|
||
import Plug.Conn<%= if @gettext do %> | ||
import <%= @web_namespace %>.Gettext<% end %> | ||
import Plug.Conn | ||
|
||
unquote(verified_routes()) | ||
end | ||
|
@@ -81,11 +82,13 @@ defmodule <%= @web_namespace %> do | |
|
||
defp html_helpers do | ||
quote do | ||
# Translation | ||
josevalim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<%= if @gettext do %>use Gettext, backend: <%= @web_namespace %>.Gettext | ||
<% end %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will leave trailing whitespace. I think the |
||
# HTML escaping functionality | ||
import Phoenix.HTML | ||
# Core UI components and translation | ||
import <%= @web_namespace %>.CoreComponents<%= if @gettext do %> | ||
import <%= @web_namespace %>.Gettext<% end %> | ||
# Core UI components | ||
import <%= @web_namespace %>.CoreComponents | ||
|
||
# Shortcut for generating JS commands | ||
alias Phoenix.LiveView.JS | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,9 +41,10 @@ defmodule <%= @web_namespace %> do | |
use Phoenix.Controller, | ||
formats: [:html, :json], | ||
layouts: [html: <%= @web_namespace %>.Layouts] | ||
|
||
import Plug.Conn<%= if @gettext do %> | ||
import <%= @web_namespace %>.Gettext<% end %> | ||
|
||
<%= if @gettext do %>use Gettext, backend: <%= @web_namespace %>.Gettext | ||
<% end %> | ||
josevalim marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will leave trailing whitespace before and after. I think the |
||
import Plug.Conn | ||
|
||
unquote(verified_routes()) | ||
end | ||
|
@@ -81,11 +82,13 @@ defmodule <%= @web_namespace %> do | |
|
||
defp html_helpers do | ||
quote do | ||
# Translation | ||
<%= if @gettext do %>use Gettext, backend: <%= @web_namespace %>.Gettext | ||
<% end %> | ||
josevalim marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will leave trailing whitespace. I think the |
||
# HTML escaping functionality | ||
import Phoenix.HTML | ||
# Core UI components and translation | ||
import <%= @web_namespace %>.CoreComponents<%= if @gettext do %> | ||
import <%= @web_namespace %>.Gettext<% end %> | ||
# Core UI components | ||
import <%= @web_namespace %>.CoreComponents | ||
|
||
# Shortcut for generating JS commands | ||
alias Phoenix.LiveView.JS | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,10 @@ defmodule <%= @web_namespace %>.CoreComponents do | |
|
||
Icons are provided by [heroicons](https://heroicons.com). See `icon/1` for usage. | ||
""" | ||
use Phoenix.Component | ||
use Phoenix.Component<%= if @gettext do %> | ||
use Gettext, backend: <%= @web_namespace %>.Gettext<% end %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is perfect! |
||
|
||
alias Phoenix.LiveView.JS<%= if @gettext do %> | ||
import <%= @web_namespace %>.Gettext<% end %> | ||
alias Phoenix.LiveView.JS | ||
|
||
@doc """ | ||
Renders flash notices. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,10 @@ defmodule <%= @web_namespace %>.CoreComponents do | |
|
||
Icons are provided by [heroicons](https://heroicons.com). See `icon/1` for usage. | ||
""" | ||
use Phoenix.Component | ||
use Phoenix.Component<%= if @gettext do %> | ||
use Gettext, backend: <%= @web_namespace %>.Gettext<% end %> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is perfect! |
||
|
||
alias Phoenix.LiveView.JS<%= if @gettext do %> | ||
import <%= @web_namespace %>.Gettext<% end %> | ||
alias Phoenix.LiveView.JS | ||
|
||
@doc """ | ||
Renders flash notices. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new lines are tricky to get right, but I am almost sure this is what is needed. You have to replicate this below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With
--gettext
:With
--no-gettext
:I think we're good? I would love to keep the
use
aboveimport
as it seems like it's a pretty common ordering. 🙃There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(this is with changes I’m about to push to be clear!)