Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yesod Julius Interpolation of Messages

Tags:

yesod

hamlet

I've been using Yesod's messages system to help keep my language consistent. For example, I have a message named MsgBrand, which gets interpolated into Hamlet files with no problem. However, I am now using a JavaScript library which needs this kind of information.

var tour = Tour.new();

tour.addSteps([
  { element: "#some-id",
    title:   "Some Title",
    content: "_{MsgTourStepFoo}"
  }
]);

However, _{MsgTourStepFoo} is appearing in the rendered JavaScript code verbatim. In other words, there is no interpolation. Is this normal or am I missing something?

like image 464
nomen Avatar asked Feb 03 '26 06:02

nomen


1 Answers

This is normal. We could have a i18n-variant of Julius, but have avoided it so far simply because it seems like it would be more confusion than it's worth. Instead, you can use getMessageRender to get the message rendering function and then call it from Julius, something like:

Haskell:
messageRender <- getMessageRender

Julius:
content: "#{messageRender MsgTourStepFoo}"
like image 175
Michael Snoyman Avatar answered Feb 05 '26 07:02

Michael Snoyman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!