[Bese-devel] about the patch "l10n/yaclml integration fixed."

Attila Lendvai attila.lendvai at gmail.com
Tue Aug 1 17:35:26 UTC 2006


hi!

i've pulled this to _ajax and i have a few questions and an alternative impl
you can find at the end of the mail...

is the :it.bese.ucw.l10n.tags really needed? i think only one or two tags
could be defined in it that could go into <ucw: (unless i'm missing some xml
namespace related reason)

and about the old <l10n:lookup tag: i had the <ucw:localized tag that you
can find below locally in my project. i propose that instead. i think no tag
is useful for resources that need arguments, they 99% of the time need more
caretaking then a simply <:as-html'ing their return value. some real-world
examples for this from my project: (i have a naming convention that
functions ending in "<>" in the :lang package are rendering to the yaclml
stream)

;; locale specific
(defresources en
  (activity-label.finder<> (entity)
                                      (<:as-html "Browsing ")
                                      (entities<> entity)))

;; the rest is not locale specific
(defun entities (entity &key capitalize-first-letter)
  (bind (((values entity-name found) (localize entity))) ;; the localize
call here localizes the entity name
    (setf entity-name (plural-of entity-name))
    (values (if capitalize-first-letter
                (capitalize-first-letter entity-name)
                entity-name)
            found)))

(defun entities<> (entity &key capitalize-first-letter)
  (bind (((values str foundp) (entities entity :capitalize-first-letter
capitalize-first-letter)))
    (<:span :class (append* (unless foundp +missing-resource-css-class+)
"entity-name")
            (<:as-html str))))


and here's the proposed alternative that i'll push unless Maciek or someone
has any objections.

#|

delete this

(defpackage :it.bese.ucw.l10n.tags
  (:nicknames #:<l10n))

(pushnew (cons "http://common-lisp.net/project/ucw/l10n/core"
               (find-package :it.bese.ucw.l10n.tags))
         yaclml:*uri-to-package*
         :test #'equal)
|#

(eval-always
  (export 'it.bese.ucw.tags::localized (find-package :it.bese.ucw.tags))
  (defparameter +missing-resource-css-class+ "missing-resource"))

(deftag-macro <ucw:localized (&body forms)
  "Just like <:as-html but calls localize on the elements before rendering"
  `(progn
    ,@(mapcar (lambda (form)
                `(bind (((values str foundp) (localize ,form)))
                  (if foundp
                      (<:as-html str)
                      (<:span :class #.+missing-resource-css-class+
                              (<:as-html str)))))
              forms)))

-- 
- attila

"- The truth is that I've been too considerate, and so became
unintentionally cruel...
- I understand.
- No, you don't understand! We don't speak the same language!"

Ingmar Bergman - Smultronstället (Wild Strawberries)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.common-lisp.net/pipermail/bese-devel/attachments/20060801/0cfe6252/attachment.html>


More information about the bese-devel mailing list