new dictionary API

8 views
Skip to first unread message

nall...@gmail.com

unread,
Jul 23, 2008, 10:05:02 AM7/23/08
to cl-terrace
Djula's internationalization API has been overhauled in the darcs repo
past 0.1.1 and the new api will be included in any new djula releases

dictionary variables are now completely separate from normal variables
[those supplied by the programmer or devel dictionaries] and have
their own syntax and namespace. dictionary variables are no longer
html escaped

so if you want to internationalize this template

<p>Click here to go to the <a href='{{zoo-link}}'>Zoo</a></p>

then create a dictionary with the contents:

(click-to-go-to-zoo english "Click here to go to the <a href='{{zoo-
link}}'>Zoo</a>" chinese "<a href='{{zoo-link}}'>I DONT KNOW CHINESE</
a>")

[note: as you can see, languages and variables no longer need to look
like lisp keywords. you can make them look like lisp keywords if
youcwant]

then change the template to

{% dictionary "/zoo-dictionary.lisp" %}
<p>{_click-to-go-to-zoo_}</p>

now (let ((*language* :english)) (render "/example-template.html" :zoo-
link "http://example.com"))

will return

<p>Click here to go to the the <a href='http://example.com'>Zoo</
a></p>

and (let ((*language* :chinese)) (render "/example-template.html" :zoo-
link "http://example.com))

will return

<p><a href='http://example.com'>I DONT KNOW CHINESE</a></p>

build the html documentation from the darcs repo version of djula for
more info

nall...@gmail.com

unread,
Jul 23, 2008, 10:10:32 AM7/23/08
to cl-terrace
also, the new terrace-file function D returns the value of dictionary
variables from specific dictionaries so you can use dictionaries to
internationalize text used programatically such as error messages,
etc. D takes a plist of variable name/value pairs like RENDER
Reply all
Reply to author
Forward
0 new messages