Commits

Martin Geisler  committed dac953c

rst2html: remove global translation object

  • Participants
  • Parent commits eb9e757

Comments (0)

Files changed (1)

 smartypants.tags_to_skip_regex = re.compile(r"<(/)?(pre|code|kbd|script|math|tt)[^>]*>",
                                             re.IGNORECASE)
 
-t = gettext.translation('kick-start', 'locale', fallback=True)
-
 
 class GettextSource(object):
-    def __init__(self, src):
+    def __init__(self, src, translation):
         object.__setattr__(self, "_src", src)
+        object.__setattr__(self, "_translation", translation)
 
     def read(self):
         text = self._src.read()
         parts = []
         for part, offset, istext in splitrst.filter(text, ['tip', 'note'], False):
             if istext:
-                part = t.ugettext(part)
+                part = self._translation.ugettext(part)
                 # filter out any directives inserted in the
                 # translation
                 parts.extend(part for part, offset, istext
         return "".join(parts)
 
     def __getattribute__(self, attr):
-        if attr in ("_src", "read"):
+        if attr in ("_src", "_translation", "read"):
             return object.__getattribute__(self, attr)
         return getattr(self._src, attr)
 
     pub.set_components(reader_name, parser_name, writer_name)
     pub.process_command_line()
     pub.set_io()
-    pub.source = GettextSource(pub.source)
+
+    t = gettext.translation('kick-start', 'locale', fallback=True)
+    pub.source = GettextSource(pub.source, t)
     pub.destination = SmartyPantsDestination(pub.destination)
 
     pub.publish(enable_exit_status=True)