jaru01

jaru01

gettext.extract not extracting strings

I’m likely missing something here. When I run:

mix gettext.extract

it just generates a file with a few default strings from core components like “Actions” and “Attempting to reconnect”.

I created a Backend as per the Github page like such:

ct@mt:~/path/to/file$ cat lib/myapp/gettext.exdefmodule MyApp.Gettext douse Gettext.Backend, otp_app: :my_append

And just for testing:

defmodule MyAppWeb.EscortLive.Index do
  use MyAppWeb, :live_view
  use Gettext, backend: MyApp.Gettext

  @impl true
  def mount(_params, _session, socket) do
    gettext("A simple test")
#...
end

But that string doesn’t get picked up. Also tried in other files with no result.

Marked As Solved

BartOtten

BartOtten

Phoenix comes with a Gettext backend generated by default. This one is also included in every view you created.

If you don’t have this line you need to include Gettext everywhere yourself.

https://github.com/BartOtten/routex_example/blob/ca65a2efffe0ed2b45cebef5626463829a6ddbdc/lib/example_web.ex#L95

If you do have that line but with another backend than you manually add in the view modules, I think you have a conflict.

Also Liked

BartOtten

BartOtten

In your Live View files you have something like use ExampleWeb, :live_view

This calls the live_view function in ExampleWeb which should include a call to html_helpers which should include use Gettext, backend: ExampleWeb.Gettext.

Notice that the Gettext usage is also part of controller
https://github.com/BartOtten/routex_example/blob/ca65a2efffe0ed2b45cebef5626463829a6ddbdc/lib/example_web.ex#L50

You say you added the use directive yourself in the Live Views. That should not be necessary as that is exactly what use ExampleWeb, :live_view does (if correct, see above)

Last Post!

jaru01

jaru01

Ok, everything solved. I forgot to include the gettext call in <%= %>. Thanks everyone for their help!

Where Next?

Popular in Questions Top

lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44778 311
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement