code: def objectlanguage(parser, token):
      
      bits = token.split_contents()
      if len(bits) == 2:
          object_var = parser.compile_filter(bits[1])
          language_var = None
      elif len(bits) == 3:
          object_var = parser.compile_filter(bits[1])
          language_var = parser.compile_filter(bits[2])
      else:
          raise TemplateSyntaxError("'%s' takes one argument (object) and has one optional argument (language)" % bits[0])
  
      nodelist = parser.parse(('endobjectlanguage',))
      parser.delete_first_token()
      return ObjectLanguageNode(nodelist, object_var, language_var)
docs: Template tag to switch an object language
      Example::
  
          {% objectlanguage object "en" %}
            {{ object.title }}
          {% endobjectlanguage %}
  
      A TranslatedObject is not affected by the ``{% language .. %}`` tag
      as it maintains it's own state. This tag temporary switches the object state.
  
      Note that using this tag is not thread-safe if the object is shared between threads.
      It temporary changes the current language of the object.