def generate_mo_file(self, locale):
        ui.info(ui.green, "Generating translation for", ui.reset,
                ui.bold, locale)
        input_file = self.get_po_file(locale)
        if not os.path.exists(input_file):
            ui.error("No .po found for locale: ", locale, "\n",
                     "(looked in %s)" % input_file, "\n",
                     "Did you run qilinguist update?")
            return

        output_file = os.path.join(self.mo_path, locale, "LC_MESSAGES",
                                   self.domain + ".mo")
        to_make = os.path.dirname(output_file)
        qisys.sh.mkdir(to_make, recursive=True)

        cmd = ["msgfmt", "--check", "--statistics"]

        # required by libqi:
        conf_file = os.path.join(self.mo_path, ".confintl")
        with open(conf_file, "w") as fp:
            fp.write("# THIS FILE IS AUTOGENERATED\n"
                     "# Do not delete or modify it\n"
                     "# This file is used to find translation dictionaries\n")

        cmd.extend(["--output-file", output_file])
        cmd.extend(["--directory", self.po_path])
        cmd.append(input_file)

        process = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                        stderr=subprocess.PIPE)
        out, err = process.communicate()
        ui.info(err.strip())
        if "untranslated" in err:
            return False, "Some untranslated messages were found"
        if process.returncode != 0:
            return False, "msgfmt failed"
        return True, ""
Generate .mo file for the given locale
dataset/ETHPy150Open aldebaran/qibuild/python/qilinguist/qigettext.py/GettextProject.generate_mo_file