Alberto Valverde schrieb:
> 
> 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

Thanks, I'll be dabbling with that today.

> 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? :)


I'm preparing a patch that

  - collects _('strings') from js via i18n collect

  - creates <catalogname>-<locale>.js-files for each locale in the 
static javascript directory via a new i18n subcommand

  - a widget that must be included on each page that defines the 
_()-function and additionally tries to include a js-catalog-file if it 
exists.

If you can wait a few days, I can send you a more polished version - or 
try and cough up one really soon. PM me in that case.

Diez

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to