(self, uploaded_file)
return wb
extract translations from po file and converts to a xlsx file

        :return: Workbook object
extract translations from po file and converts to a xlsx file
extract translations from po file and converts to a xlsx file
def _generate_excel_file(self, uploaded_file):
        """
        extract translations from po file and converts to a xlsx file

        :return: Workbook object
        """
        po_file = polib.pofile(uploaded_file.read().decode('utf-8'))
        wb = openpyxl.Workbook()
        ws = wb.worksheets[0]
        ws.title = "Translations"
        ws.append(['source', 'translation', 'context', 'occurrence'])
        for po_entry in po_file:
            ws.append([po_entry.msgid, po_entry.msgstr, po_entry.msgctxt,
                       po_entry.occurrences[0][0] if po_entry.occurrences else ''])
        return wb
def _generate_excel_file ( self , uploaded_file ) : po_file = polib . pofile ( uploaded_file . read ( ) . decode ( 'utf-8' ) ) wb = openpyxl . Workbook ( ) ws = wb . worksheets [ 0 ] ws . title = "Translations" ws . append ( [ 'source' , 'translation' , 'context' , 'occurrence' ] ) for po_entry in po_file : ws . append ( [ po_entry . msgid , po_entry . msgstr , po_entry . msgctxt , po_entry . occurrences [ 0 ] [ 0 ] if po_entry . occurrences else '' ] ) return wb