c3po/converters/po_ods.py
def po_to_ods(languages, locale_root, po_files_path, temp_file_path):
    """
    Converts po file to csv GDocs spreadsheet readable format.
    :param languages: list of language codes
    :param locale_root: path to locale root folder containing directories
                        with languages
    :param po_files_path: path from lang directory to po file
    :param temp_file_path: path where temporary files will be saved
    """
    title_row = ['file', 'comment', 'msgid']
    title_row += map(lambda s: s + ':msgstr', languages)

    ods = ODS()

    _prepare_ods_columns(ods, title_row)

    po_files = _get_all_po_filenames(locale_root, languages[0], po_files_path)

    i = 1
    for po_filename in po_files:
        po_file_path = os.path.join(locale_root, languages[0],
                                    po_files_path, po_filename)

        start_row = i

        po = polib.pofile(po_file_path)
        for entry in po:
            meta = dict(entry.__dict__)
            meta.pop('msgid', None)
            meta.pop('msgstr', None)
            meta.pop('tcomment', None)

            ods.content.getSheet(1)
            ods.content.getCell(0, i).stringValue(
                str(meta)).setCellColor(settings.EVEN_COLUMN_BG_COLOR)

            ods.content.getSheet(0)
            ods.content.getCell(0, i) \
                .stringValue(po_filename) \
                .setCellColor(settings.ODD_COLUMN_BG_COLOR)
            ods.content.getCell(1, i) \
                .stringValue(_escape_apostrophe(entry.tcomment)) \
                .setCellColor(settings.ODD_COLUMN_BG_COLOR)
            ods.content.getCell(2, i) \
                .stringValue(_escape_apostrophe(entry.msgid)) \
                .setCellColor(settings.EVEN_COLUMN_BG_COLOR)
            ods.content.getCell(3, i) \
                .stringValue(_escape_apostrophe(entry.msgstr))\
                .setCellColor(settings.ODD_COLUMN_BG_COLOR)

            i += 1

        _write_trans_into_ods(ods, languages, locale_root,
                              po_files_path, po_filename, start_row)

    ods.save(temp_file_path)
def po_to_ods(languages, locale_root, po_files_path, temp_file_path):
    """
    Converts po file to csv GDocs spreadsheet readable format.
    :param languages: list of language codes
    :param locale_root: path to locale root folder containing directories
                        with languages
    :param po_files_path: path from lang directory to po file
    :param temp_file_path: path where temporary files will be saved
    """
    title_row = ['file', 'comment', 'msgid']
    title_row += map(lambda s: s + ':msgstr', languages)

    ods = ODS()

    _prepare_ods_columns(ods, title_row)

    po_files = _get_all_po_filenames(locale_root, languages[0], po_files_path)

    i = 1
    for po_filename in po_files:
        po_file_path = os.path.join(locale_root, languages[0],
                                    po_files_path, po_filename)

        start_row = i

        po = polib.pofile(po_file_path)
        for entry in po:
            meta = dict(entry.__dict__)
            meta.pop('msgid', None)
            meta.pop('msgstr', None)
            meta.pop('tcomment', None)

            ods.content.getSheet(1)
            ods.content.getCell(0, i).stringValue(
                str(meta)).setCellColor(settings.EVEN_COLUMN_BG_COLOR)

            ods.content.getSheet(0)
            ods.content.getCell(0, i) \
                .stringValue(po_filename) \
                .setCellColor(settings.ODD_COLUMN_BG_COLOR)
            ods.content.getCell(1, i) \
                .stringValue(_escape_apostrophe(entry.tcomment)) \
                .setCellColor(settings.ODD_COLUMN_BG_COLOR)
            ods.content.getCell(2, i) \
                .stringValue(_escape_apostrophe(entry.msgid)) \
                .setCellColor(settings.EVEN_COLUMN_BG_COLOR)
            ods.content.getCell(3, i) \
                .stringValue(_escape_apostrophe(entry.msgstr))\
                .setCellColor(settings.ODD_COLUMN_BG_COLOR)

            i += 1

        _write_trans_into_ods(ods, languages, locale_root,
                              po_files_path, po_filename, start_row)

    ods.save(temp_file_path)
Converts po file to csv GDocs spreadsheet readable format.
    :param languages: list of language codes
    :param locale_root: path to locale root folder containing directories
                        with languages
    :param po_files_path: path from lang directory to po file
    :param temp_file_path: path where temporary files will be saved