Показаны сообщения с ярлыком In English. Показать все сообщения
Показаны сообщения с ярлыком In English. Показать все сообщения

вторник, 17 мая 2011 г.

How do I disable caching in python gettext and django gettext?

For disabling cache in python-gettext module you are to edit gettext module.

Execute the command below to get known where you're python-gettext module is:
$ python -c "import gettext; print gettext.__file__"
/usr/lib/python2.6/gettext.py


Then open that file and find lines in translation() function:
for mofile in mofiles:
    key = os.path.abspath(mofile)
    t = _translations.get(key)
    if t is None:
        t = _translations.setdefault(key, class_(open(mofile, 'rb')))


Replace it with:
for mofile in mofiles:
    key = os.path.abspath(mofile)
    t = _translations.get(key)
    t = None # new line
    if t is None:
        t = _translations.setdefault(key, class_(open(mofile, 'rb')))


It will simply disable gettext's cache for your debugging purposes. I wouldn't recomend this patch to use in production.

However if you use django framework it won't solve your caching problems. I wonder to know why but django uses its own gettext caching layer. To disable it simply replace in file utils/translation/trans_real.py:
def translation(language):
    """
    Returns a translation object.

    This translation object will be constructed out of multiple GNUTranslations
    objects by merging their catalogs. It will construct a object for the
    requested language and add a fallback to the default language, if it's
    different from the requested language.
    """
    global _translations

    t = _translations.get(language, None)
    if t is not None:
        return t


with:
def translation(language):
    """
    Returns a translation object.

    This translation object will be constructed out of multiple GNUTranslations
    objects by merging their catalogs. It will construct a object for the
    requested language and add a fallback to the default language, if it's
    different from the requested language.
    """
    global _translations

    t = _translations.get(language, None)
    t = None # new line
    if t is not None:
        return t

Patches available here: for gettext.py and for trans_real.py

вторник, 5 апреля 2011 г.

Feed for English Cafe only (from ESLPod.com)

Below is an RSS feed that contains only "English Cafe" episodes from www.eslpod.com podcast for english learning.
Original ESLPod feed has two types of episodes, regular ones and "English cafe". If you prefer to listen only the last ones then the feed below is for you.

Drop it to your iTunes and enjoy!

http://pipes.yahoo.com/pipes/pipe.run?_id=7909dfadbf01c54a83746ebe97ea6189&_render=rss

вторник, 26 октября 2010 г.