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

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
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
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

Other popular topics Top

jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40042 209
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement