Localizing a string containing links

17 views
Skip to first unread message

Joe Barnes

unread,
Nov 20, 2016, 10:49:35 PM11/20/16
to Lift
Lately I've been helping some folks understand how to internationalize/localize their app to support multiple languages. I ran into a case where there is a string which contains two phrases (Terms of Use and Privacy Policy) both of which should be a href links. I know I could sorta brute force my way by localizing each of the 5 pieces individually, but that's a bit gross. Is there a good way to do this that I'm not aware of?

Joe

Antonio Salazar Cardozo

unread,
Nov 21, 2016, 9:15:44 AM11/21/16
to Lift
That's a really nasty/annoying problem, unfortunately. Lift supports XML
translation files that can include more complex stuff, IIRC, but I've never
used it (it's also a lot more verbose to work with, unfortunately). In our
case, we've been using a {}-delimited placeholder; e.g.:

myMessage-link=You agree to the {terms} and the {privacy-policy}.

Unfortunately you kind of have to hand-parse it, and then you inline an
`<a href` construction in the Scala code. It ain't pretty.

Another option that you could use is using markdown with a URL placeholder
that then gets replaced and run through lift-markdown.
Thanks,
Antonio

Peter Petersson

unread,
Nov 21, 2016, 12:36:11 PM11/21/16
to lif...@googlegroups.com

I tend to use lifts XML resource handling and for a case like that I wold probably do something like the below and use a NodeSeq.

&lt;res name="page.section.temsAndPolicy" lang="en" default="true"&gt;
  &lt;span&gt;&lt;a href="xxx"&gt;Terms of Use&lt;/a&gt; and &lt;a href="yyy"&gt;Privacy Policy&lt;/a&gt;&lt;/span&gt;
&lt;/res&gt;

best regards Peter Petersson

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Peter Petersson

unread,
Nov 21, 2016, 12:41:02 PM11/21/16
to lif...@googlegroups.com

ha ha that didn't look to good I though I needed to escape the html in the mail (to make it render as text), here is the correct resource code snippet again

<res name="page.section.temsAndPolicy" lang="en" default="true">
  <span><a href="xxx">Terms of Use</a> and <a href="yyy">Privacy Policy</a><span>
<res>

best regards Peter Petersson

Antonio Salazar Cardozo

unread,
Nov 22, 2016, 7:19:42 AM11/22/16
to Lift
Can you use this and properties files simultaneously, or do you have to go
all in on one or the other?
Thanks,
Antonio
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+unsubscribe@googlegroups.com.

Peter Petersson

unread,
Nov 22, 2016, 10:36:01 AM11/22/16
to liftweb

My guess is that you can mix them. I base this assumption on, that for example, ProtoUser uses som lift built-in properties that I have used or even overrided using xml properties I have however not tested it in any other way.

Joe Barnes

unread,
Nov 22, 2016, 5:08:08 PM11/22/16
to Lift
Thanks for the ideas. Both are certainly preferable to slamming multiple strings together!

Joe
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

--
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code

---
You received this message because you are subscribed to the Google Groups "Lift" group.
To unsubscribe from this group and stop receiving emails from it, send an email to liftweb+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages