예제 #1
0
def convert_idml(inputfile, outputfile, template):
    """Convert an IDML package to PO."""
    store = factory.getobject(outputfile)

    contents = open_idml(inputfile)

    id_maker = IdMaker()  # Create it here to avoid having repeated ids.

    for filename, translatable_file in six.iteritems(contents):
        parse_state = ParseState(NO_TRANSLATE_ELEMENTS, INLINE_ELEMENTS)
        po_store_adder = make_postore_adder(store, id_maker, filename)
        build_idml_store(BytesIO(translatable_file),
                         store,
                         parse_state,
                         store_adder=po_store_adder)

    store.save()
    return True
예제 #2
0
    def convertfile(storefile):
        store = pofile()

        contents = open_idml(storefile)

        # Create it here to avoid having repeated ids.
        id_maker = IdMaker()

        for filename, translatable_file in contents.items():
            parse_state = ParseState(NO_TRANSLATE_ELEMENTS, INLINE_ELEMENTS)
            po_store_adder = make_postore_adder(store, id_maker, filename)
            build_idml_store(
                BytesIO(translatable_file),
                store,
                parse_state,
                store_adder=po_store_adder,
            )

        return store
예제 #3
0
def convert_idml(inputfile, outputfile, template):
    """Convert an IDML package to PO."""
    # Since the convertoptionsparser will give us an open file, we risk that
    # it could have been opened in non-binary mode on Windows, and then we'll
    # have problems, so let's make sure we have what we want.
    inputfile.close()
    inputfile = file(inputfile.name, mode='rb')

    store = factory.getobject(outputfile)

    contents = open_idml(inputfile)

    id_maker = IdMaker()  # Create it here to avoid having repeated ids.

    for filename, translatable_file in six.iteritems(contents):
        parse_state = ParseState(NO_TRANSLATE_ELEMENTS, INLINE_ELEMENTS)
        po_store_adder = make_postore_adder(store, id_maker, filename)
        build_idml_store(BytesIO(translatable_file),
                         store,
                         parse_state,
                         store_adder=po_store_adder)

    store.save()
    return True