<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def xgettext(self, template):
 """Extracts to be translated strings from template and turns it into po format."""


        cmd = 'xgettext -d django -L Python --keyword=gettext_noop \
            --keyword=gettext_lazy --keyword=ngettext_lazy:1,2 --from-code=UTF-8 \
            --output=- -'

        p = subprocess.Popen(cmd, shell=True, stdin=subprocess.PIPE,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
        (msg, err) = p.communicate(input=templatize(template))

        if err:
            # dont raise exception, some stuff in stderr are just warmings
            logging.warning(err)

        if XGETTEXT_REENCODES_UTF8:
            return msg.decode('utf-8').encode('iso-8859-1')

        return msg