On May 17, 2007, at 5:49 PM, Diez B. Roggisch wrote:
>
> Hi,
>
> I'm currently working on making gettext-support available for
> javascript
> (some other post explaining that + a patch will hopefully follow
> soon.)
>
> To do so, I have to include catalog-files for javascript. So the
> obvious
> idea is to use
>
> /project/<catalog-name>-<locale>.js
>
> However, often the locale is e.g. "en_US", but the catalog is only
> available as "en".
>
> So I need a way to check if a certain static file I'm providing as
> JSLink actually exists. I presume this should be somehow doable using
> cherrypy, a subject I'm pretty unfamiliar with.
>
> Any suggestions would be highly appreciated.
import os
from cherrypy.config import configs
def linked_file_exists(widget):
key = '/tg_widgets/%s' % widget.mod
wp = configs.get(key)
if wp:
dir = wp.get('static_filter.dir')
if dir:
path = os.path.join(dir, widget.name)
return os.path.exists(path)
return False
>>> linked_file_exists(mochikit)
True
However, this *will* break in TG 1.1 since the config chages
dramatically... however, should be easily adaptable and will work for
sure in all 1.0.x series.
BTW, Just happens that I'll have t tacke JS localization problems in
very short time... any pointers or code to share? :)
Alberto
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---