PKq³7m »éébabeldjango/__init__.py# -*- coding: utf-8 -*- # # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. PKSn7h.ôŠŠbabeldjango/__init__.pyc;ò 6³ÄFc@sdS(N((((s:build/bdist.darwin-8.10.1-i386/egg/babeldjango/__init__.pys?sPK`7ÎÈ ”ÄÄbabeldjango/extract.py# -*- coding: utf-8 -*- # # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. from babel.core import * from django.conf import settings settings.configure(USE_I18N=True) from django.template import Lexer, TOKEN_TEXT, TOKEN_VAR, TOKEN_BLOCK from django.utils.translation.trans_real import inline_re, block_re, \ endblock_re, plural_re, \ constant_re def extract_django(fileobj, keywords, comment_tags, options): """Extract messages from Django template files. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions :param comment_tags: a list of translator tags to search for and include in the results :param options: a dictionary of additional options (optional) :return: an iterator over ``(lineno, funcname, message, comments)`` tuples :rtype: ``iterator`` """ intrans = False inplural = False singular = [] plural = [] lineno = 1 for t in Lexer(fileobj.read(), None).tokenize(): lineno += t.contents.count('\n') if intrans: if t.token_type == TOKEN_BLOCK: endbmatch = endblock_re.match(t.contents) pluralmatch = plural_re.match(t.contents) if endbmatch: if inplural: yield lineno, 'ngettext', (unicode(''.join(singular)), unicode(''.join(plural))), [] else: yield lineno, None, unicode(''.join(singular)), [] intrans = False inplural = False singular = [] plural = [] elif pluralmatch: inplural = True else: raise SyntaxError('Translation blocks must not include ' 'other block tags: %s' % t.contents) elif t.token_type == TOKEN_VAR: if inplural: plural.append('%%(%s)s' % t.contents) else: singular.append('%%(%s)s' % t.contents) elif t.token_type == TOKEN_TEXT: if inplural: plural.append(t.contents) else: singular.append(t.contents) else: if t.token_type == TOKEN_BLOCK: imatch = inline_re.match(t.contents) bmatch = block_re.match(t.contents) cmatches = constant_re.findall(t.contents) if imatch: g = imatch.group(1) if g[0] == '"': g = g.strip('"') elif g[0] == "'": g = g.strip("'") yield lineno, None, unicode(g), [] elif bmatch: intrans = True inplural = False singular = [] plural = [] elif cmatches: for cmatch in cmatches: yield lineno, None, unicode(cmatch), [] elif t.token_type == TOKEN_VAR: parts = t.contents.split('|') cmatch = constant_re.match(parts[0]) if cmatch: yield lineno, None, unicode(cmatch.group(1)), [] for p in parts[1:]: if p.find(':_(') >= 0: p1 = p.split(':',1)[1] if p1[0] == '_': p1 = p1[1:] if p1[0] == '(': p1 = p1.strip('()') if p1[0] == "'": p1 = p1.strip("'") elif p1[0] == '"': p1 = p1.strip('"') yield lineno, None, unicode(p1), [] PKSn7`·pH__babeldjango/extract.pyc;ò CfÉFc@sudkTdklZeideƒdklZlZlZl Z dk l Z l Z l Z lZlZd„ZdS((s*(ssettingssUSE_I18N(sLexers TOKEN_TEXTs TOKEN_VARs TOKEN_BLOCK(s inline_resblock_res endblock_res plural_res constant_reccs,t}t}g} g}d} xt|iƒt ƒi ƒD]ê}| |i i dƒ7} |og|itjoÍti|i ƒ}ti|i ƒ} |oz|o8| dtdi| ƒƒtdi|ƒƒfgfVn | t tdi| ƒƒgfVt}t}g} g}qÀ| o t}qÀtd|i ƒ‚q$|itjo7|o|id|i ƒqÀ| id|i ƒq$|itjo/|o|i|i ƒqÀ| i|i ƒq$q:|itjoti|i ƒ}ti|i ƒ} t i!|i ƒ} |oq|i#dƒ}|ddjo|i%dƒ}n%|dd jo|i%d ƒ}n| t t|ƒgfVq$| ot}t}g} g}q$| o+x(| D]}| t t|ƒgfVq³Wq$q:|itjo9|i i'd ƒ}t i|dƒ}|o#| t t|i#dƒƒgfVnxç|dD]×}|i*d ƒdjo»|i'd dƒd}|dd jo|d}n|ddjo|i%dƒ}n|dd jo|i%d ƒ}n%|ddjo|i%dƒ}n| t t|ƒgfVqEqEWq:q:WdS(s3Extract messages from Django template files. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions :param comment_tags: a list of translator tags to search for and include in the results :param options: a dictionary of additional options (optional) :return: an iterator over ``(lineno, funcname, message, comments)`` tuples :rtype: ``iterator`` is sngettextss8Translation blocks must not include other block tags: %ss%%(%s)sis"s's|s:_(s:s_s(s()N(,sFalsesintranssinpluralssingularspluralslinenosLexersfileobjsreadsNonestokenizestscontentsscounts token_types TOKEN_BLOCKs endblock_resmatchs endbmatchs plural_res pluralmatchsunicodesjoinsTrues SyntaxErrors TOKEN_VARsappends TOKEN_TEXTs inline_resimatchsblock_resbmatchs constant_resfindallscmatchessgroupsgsstripscmatchssplitspartsspsfindsp1(sfileobjskeywordss comment_tagssoptionsscmatchsintranssinpluralsimatchspartsslinenos pluralmatchssingularsbmatchscmatchessp1sgspluralspsts endbmatch((s9build/bdist.darwin-8.10.1-i386/egg/babeldjango/extract.pysextract_djangosŒ 8   "# N(s babel.cores django.confssettingss configuresTruesdjango.templatesLexers TOKEN_TEXTs TOKEN_VARs TOKEN_BLOCKs#django.utils.translation.trans_reals inline_resblock_res endblock_res plural_res constant_resextract_django( s TOKEN_VARs endblock_resblock_ressettingssLexers plural_res inline_res TOKEN_BLOCKs constant_res TOKEN_TEXTsextract_django((s9build/bdist.darwin-8.10.1-i386/egg/babeldjango/extract.pys?s  %PK•f7±ä>‚¸¸babeldjango/middleware.py# -*- coding: utf-8 -*- # # Copyright (C) 2007 Edgewall Software # All rights reserved. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms # are also available at http://babel.edgewall.org/wiki/License. # # This software consists of voluntary contributions made by many # individuals. For the exact contribution history, see the revision # history and logs, available at http://babel.edgewall.org/log/. from babel import Locale, UnknownLocaleError from django.conf import settings try: from threading import local except ImportError: from django.utils._threading_local import local __all__ = ['get_current_locale', 'LocaleMiddleware'] _thread_locals = local() def get_current_locale(): """Get current locale data outside views. See http://babel.edgewall.org/wiki/ApiDocs/babel.core for Locale objects documentation """ return getattr(_thread_locals, 'locale', None) class LocaleMiddleware(object): """Simple Django middleware that makes available a Babel `Locale` object via the `request.locale` attribute. """ def process_request(self, request): try: code = getattr(request, 'LANGUAGE_CODE', settings.LANGUAGE_CODE) locale = Locale.parse(code, sep='-') except (ValueError, UnknownLocaleError): pass else: _thread_locals.locale = request.locale = locale PKSn7f¾]©©babeldjango/middleware.pyc;ò {rÉFc@sŒdklZlZdklZydklZWn ej odklZnXddgZ eƒZ d„Z de fd„ƒYZ dS((sLocalesUnknownLocaleError(ssettings(slocalsget_current_localesLocaleMiddlewarecCsttdtƒSdS(s‹Get current locale data outside views. See http://babel.edgewall.org/wiki/ApiDocs/babel.core for Locale objects documentation slocaleN(sgetattrs_thread_localssNone(((s<build/bdist.darwin-8.10.1-i386/egg/babeldjango/middleware.pysget_current_localescBstZdZd„ZRS(srSimple Django middleware that makes available a Babel `Locale` object via the `request.locale` attribute. cCs^y.t|dtiƒ}ti|ddƒ}Wntt fj onX|t _|_dS(Ns LANGUAGE_CODEsseps-( sgetattrsrequestssettingss LANGUAGE_CODEscodesLocalesparseslocales ValueErrorsUnknownLocaleErrors_thread_locals(sselfsrequestscodeslocale((s<build/bdist.darwin-8.10.1-i386/egg/babeldjango/middleware.pysprocess_request's (s__name__s __module__s__doc__sprocess_request(((s<build/bdist.darwin-8.10.1-i386/egg/babeldjango/middleware.pysLocaleMiddleware"s N(sbabelsLocalesUnknownLocaleErrors django.confssettingss threadingslocals ImportErrorsdjango.utils._threading_locals__all__s_thread_localssget_current_localesobjectsLocaleMiddleware(s__all__ssettingssLocalesUnknownLocaleErrorsget_current_locales_thread_localsslocalsLocaleMiddleware((s<build/bdist.darwin-8.10.1-i386/egg/babeldjango/middleware.pys?s    PKSn7“×2EGG-INFO/dependency_links.txt PKSn7|FzLLEGG-INFO/entry_points.txt [babel.extractors] django = babeldjango.extract:extract_django PKSn7²›UEGG-INFO/PKG-INFOMetadata-Version: 1.0 Name: BabelDjango Version: 0.2 Summary: Utilities for using Babel in Django Home-page: http://babel.edgewall.org/wiki/BabelDjango Author: Edgewall Software Author-email: python-babel@googlegroups.com License: BSD Description: UNKNOWN Platform: UNKNOWN PKSn7ÁVpEGG-INFO/requires.txtBabelPKSn7ߥ耀EGG-INFO/SOURCES.txtCOPYING README.txt setup.py BabelDjango.egg-info/PKG-INFO BabelDjango.egg-info/SOURCES.txt BabelDjango.egg-info/dependency_links.txt BabelDjango.egg-info/entry_points.txt BabelDjango.egg-info/requires.txt BabelDjango.egg-info/top_level.txt babeldjango/__init__.py babeldjango/extract.py babeldjango/middleware.py babeldjango/templatetags/__init__.py babeldjango/templatetags/babel.py PKSn7†QŒ EGG-INFO/top_level.txtbabeldjango PKSn7“×2EGG-INFO/zip-safe PKq³7m »éé¤babeldjango/__init__.pyPKSn7h.ôŠŠ¤babeldjango/__init__.pycPK`7ÎÈ ”ÄĤÞbabeldjango/extract.pyPKSn7`·pH__¤Öbabeldjango/extract.pycPK•f7±ä>‚¸¸¤j#babeldjango/middleware.pyPKSn7f¾]©©¤Y)babeldjango/middleware.pycPKSn7“×2¤:1EGG-INFO/dependency_links.txtPKSn7|FzLL¤v1EGG-INFO/entry_points.txtPKSn7²›U¤ù1EGG-INFO/PKG-INFOPKSn7ÁVp¤:3EGG-INFO/requires.txtPKSn7ߥ耀¤r3EGG-INFO/SOURCES.txtPKSn7†QŒ ¤$5EGG-INFO/top_level.txtPKSn7“×2¤d5EGG-INFO/zip-safePK |”5