예제 #1
0
    def intl_update(self):
        ui.info(ui.blue, "::", ui.reset, "Generating message catalogs ...")
        import sphinx
        from sphinx_intl.commands import run as sphinx_intl_run
        # First step: run sphinx-build -b gettext
        cmd = [sys.executable, "-c", self.build_dir, "-b", "gettext"]
        cmd.append(self.source_dir)
        locale_dir = os.path.join(self.source_dir, "locale")
        cmd.append(locale_dir)
        rc = 0
        try:
            sphinx.main(argv=cmd)
        except SystemExit as e:
            rc = e.code
        if rc != 0:
            raise SphinxBuildError(self)

        ui.info()

        # Second step: run sphinx-intl update -l <lingua> for every lingua
        ui.info(ui.blue, "::", ui.reset, "Updating .po files ...")
        for i, lingua in enumerate(self.linguas):
            ui.info_count(i, len(self.linguas), ui.blue, lingua)
            cmd = [
                "update", "-c",
                os.path.join(self.build_dir, "conf.py"), "--pot-dir",
                locale_dir, "--locale-dir", locale_dir, "--language", lingua
            ]
            sphinx_intl_run(cmd)
예제 #2
0
    def intl_update(self):
        ui.info(ui.blue, "::", ui.reset, "Generating message catalogs ...")
        import sphinx
        from sphinx_intl.commands import run as sphinx_intl_run
        # First step: run sphinx-build -b gettext
        cmd = [sys.executable, "-c", self.build_dir, "-b", "gettext"]
        cmd.append(self.source_dir)
        locale_dir = os.path.join(self.source_dir, "locale")
        cmd.append(locale_dir)
        rc = 0
        try:
            sphinx.main(argv=cmd)
        except SystemExit as e:
            rc = e.code
        if rc != 0:
            raise SphinxBuildError(self)

        ui.info()

        # Second step: run sphinx-intl update -l <lingua> for every lingua
        ui.info(ui.blue, "::", ui.reset, "Updating .po files ...")
        for i, lingua in enumerate(self.linguas):
            ui.info_count(i, len(self.linguas), ui.blue, lingua)
            cmd = ["update",
                "-c", os.path.join(self.build_dir, "conf.py"),
                "--pot-dir", locale_dir,
                "--locale-dir", locale_dir,
                "--language", lingua]
            sphinx_intl_run(cmd)
예제 #3
0
 def intl_build(self, language):
     from sphinx_intl.commands import run as sphinx_intl_run
     locale_dir = os.path.join(self.source_dir, "locale")
     ui.info(ui.blue, "::", ui.reset, "Building .mo files ...")
     cmd = [
         "build", "-c",
         os.path.join(self.build_dir, "conf.py"), "--pot-dir", locale_dir,
         "--locale-dir", locale_dir, "--language", language
     ]
     sphinx_intl_run(cmd)
예제 #4
0
 def intl_build(self, language):
     from sphinx_intl.commands import run as sphinx_intl_run
     locale_dir = os.path.join(self.source_dir, "locale")
     ui.info(ui.blue, "::", ui.reset, "Building .mo files ...")
     cmd = ["build",
         "-c", os.path.join(self.build_dir, "conf.py"),
         "--pot-dir", locale_dir,
         "--locale-dir", locale_dir,
         "--language", language]
     sphinx_intl_run(cmd)