comparison genshi/filters/i18n.py @ 882:6f49c23045b1

Fix regression in [1099]: templates must not have an implicit loader during message extraction.
author cmlenz
date Fri, 16 Apr 2010 12:48:05 +0000
parents 9786aa263217
children 18dee397f8e1
comparison
equal deleted inserted replaced
881:fc1e28cb0bee 882:6f49c23045b1
401 s, p, n) 401 s, p, n)
402 402
403 # XXX: should we test which form was chosen like this!?!?!? 403 # XXX: should we test which form was chosen like this!?!?!?
404 # There should be no match in any catalogue for these singular and 404 # There should be no match in any catalogue for these singular and
405 # plural test strings 405 # plural test strings
406 singular_test = ur'O\x85\xbe\xa9\xa8az\xc3?\xe6\xa1\x02n\x84\x93' 406 singular_test = u'O\x85\xbe\xa9\xa8az\xc3?\xe6\xa1\x02n\x84\x93'
407 plural_test = ur'\xcc\xfb+\xd3Pn\x9d\tT\xec\x1d\xda\x1a\x88\x00' 407 plural_test = u'\xcc\xfb+\xd3Pn\x9d\tT\xec\x1d\xda\x1a\x88\x00'
408 translation = ngettext(singular_test, plural_test, 408 translation = ngettext(singular_test, plural_test,
409 self.numeral.evaluate(ctxt)) 409 self.numeral.evaluate(ctxt))
410 if translation==singular_test: 410 if translation==singular_test:
411 chosen_msgbuf = singular_msgbuf 411 chosen_msgbuf = singular_msgbuf
412 chosen_stream = singular_stream 412 chosen_stream = singular_stream
921 """ 921 """
922 922
923 def __init__(self, directive=None): 923 def __init__(self, directive=None):
924 """Initialize the message buffer. 924 """Initialize the message buffer.
925 925
926 :param params: comma-separated list of parameter names 926 :param directive: the directive owning the buffer
927 :type params: `basestring` 927 :type directive: I18NDirective
928 :param lineno: the line number on which the first stream event
929 belonging to the message was found
930 """ 928 """
931 # params list needs to be copied so that directives can be evaluated 929 # params list needs to be copied so that directives can be evaluated
932 # more than once 930 # more than once
933 self.orig_params = self.params = directive.params[:] 931 self.orig_params = self.params = directive.params[:]
934 self.directive = directive 932 self.directive = directive
1222 include_attrs = include_attrs.split() 1220 include_attrs = include_attrs.split()
1223 include_attrs = [QName(attr) for attr in include_attrs] 1221 include_attrs = [QName(attr) for attr in include_attrs]
1224 1222
1225 tmpl = template_class(fileobj, filename=getattr(fileobj, 'name', None), 1223 tmpl = template_class(fileobj, filename=getattr(fileobj, 'name', None),
1226 encoding=encoding) 1224 encoding=encoding)
1225 tmpl.loader = None
1227 1226
1228 translator = Translator(None, ignore_tags, include_attrs, extract_text) 1227 translator = Translator(None, ignore_tags, include_attrs, extract_text)
1229 if hasattr(tmpl, 'add_directives'): 1228 if hasattr(tmpl, 'add_directives'):
1230 tmpl.add_directives(Translator.NAMESPACE, translator) 1229 tmpl.add_directives(Translator.NAMESPACE, translator)
1231 for message in translator.extract(tmpl.stream, gettext_functions=keywords): 1230 for message in translator.extract(tmpl.stream, gettext_functions=keywords):
Copyright (C) 2012-2017 Edgewall Software