Kurisu

Kurisu

Will the following module attribute work as expected?

@msg gettext(
         "Sorry, your account must first be validated by our admins before " <>
           "you can access the requested page. Once this is the case, you will " <>
           "receive an email notification."
       )

Please I would like to know if using the string concatenation operator <> like that, will prevent Gettext from extracting the full string when adding translations.

I’m not yet at this step, but I would better know not relying on that before having a bunch of this to fix later.

Thanks.

Marked As Solved

mindok

mindok

It’s very quick to spin up a new Phoenix project with Gettext infrastructure and see for yourself.

However, I would guess not, but not for the reasons you think… Gettext is evaluated at run-time based on a locale set for the current active process, whereas module attributes are evaluated at compile-time.

Building a long string as a module attribute will work, e.g.:

@msg "Sorry, your account must first be validated by our admins before " <>
           "you can access the requested page. Once this is the case, you will " <>
           "receive an email notification."

But then your calls to Gettext need to be made in your run-time code.

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
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
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
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

Other popular topics Top

New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 55125 245
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
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
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New

We're in Beta

About us Mission Statement