Esempio n. 1
0
    def push_trans_command(self, zanata, transfolder, project_id, iteration_id, lang_list, locale_map, project_type, merge):
        publicanutil = PublicanUtility()

        for item in lang_list:
            if not locale_map:
                lang = item
            else:
                if item in locale_map:
                    lang = locale_map[item]
                else:
                    lang = item

            self.log.info("\nPushing %s translation for %s to server:"%(item, project_id))

            if project_type == "podir":
                folder = os.path.join(transfolder, item)

                if not os.path.isdir(folder):
                    self.log.error("Can not find translation, please specify path of the translation folder")
                    continue

                filelist = publicanutil.get_file_list(folder, ".po")

                for filepath in filelist:
                    self.log.info("\nPushing the content of %s to server:"%filepath)
                    filename = publicanutil.strip_path(filepath, folder, '.po')

                    if '/' in filename:
                        request_name = filename.replace('/', ',')
                    else:
                        request_name = filename

                    body = publicanutil.pofile_to_json(filepath)

                    if not body:
                        self.log.error("No content or all entries are obsolete in %s"%filepath)
                        sys.exit(1)

                    self.commit_translation(zanata, project_id, iteration_id, request_name, filepath, lang, body, merge)