Example #1
0
    def processingFilePair(self):

        from_po_doc = to_po_doc = None

        has_from = (self.from_vi_po != None)
        has_to = (self.to_vi_po != None)

        #print("processingFilePair: has_from={}, has_to={}".format(has_from, has_to))

        if (has_from):
            from_po_doc = Document(self.from_vi_po)
            from_po_doc.loadPOText()
            #print(from_po_doc)

        if (has_to):
            to_po_doc = Document(self.to_vi_po)
            to_po_doc.loadPOText()
            #print(to_po_doc)

        if ((self.docEventHandler != None)
                and isinstance(self.docEventHandler, TwoDocumentAction)):
            self.docEventHandler.setArgs(from_po_doc, to_po_doc)
            self.docEventHandler.run()

        #if (po_doc.isDirty()): print(po_doc)
        if (has_to and to_po_doc.isDirty()):
            if (self.out_vi_po == None):
                print("Saving changes to:{}".format(to_po_doc.path))
                to_po_doc.saveText(out_path=None)
            else:
                print("Saving changes to otherfile:{}".format(self.out_vi_po))
                to_po_doc.saveText(out_path=self.out_vi_po)
Example #2
0
    def makeDictionary(self, po_path) -> dict:
        from_path = po_path
        has_path = (po_path != None) and (os.path.isdir(po_path))

        if (not has_path):
            return

        master_dict = {}
        print("makeDictionary from: {}".format(from_path))

        from_getter = POBasic(from_path, False)
        from_po_dir_list_sorted = from_getter.getSortedPOFileListRelative()

        for (index, to_vi_po_file) in enumerate(from_po_dir_list_sorted):
            if (len(to_vi_po_file) <= 0):
                continue

            to_vi_po = os.path.join(po_path, to_vi_po_file)
            po_doc = Document(to_vi_po)
            po_doc.loadPOText()
            translated_dict = po_doc.getDictionary()
            master_dict.update(translated_dict)

        print("number of dict items: {}".format(len(master_dict)))
        return master_dict