Skip to content

Commit

Permalink
setup.py: Add translation
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Jun 11, 2024
1 parent b15e80d commit b918b43
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#!/usr/bin/env python3

import io
import os
import contextlib
import importlib.metadata
import subprocess
import warnings
import stat
from os import path, walk

from setuptools import setup, find_packages
from setuptools.command.install import install

with io.open('README.pypi', 'r', encoding='utf-8') as f:
ABOUT = f.read()
Expand Down Expand Up @@ -74,6 +79,29 @@ def include_documentation(local_dir, install_dir):
DATA_FILES.extend(doc_files)


class InstallMultilingualCommand(install):
def run(self):
install.run(self)
self.compile_to_multilingual()

@staticmethod
def compile_to_multilingual():
if importlib.metadata.version("orange3") < "3.38":
return
try:
import trubar
except ImportError:
warnings.warn("Install `trubar` for compiling translations")
return

package_dir = os.path.dirname(os.path.abspath(__file__))
with contextlib.chdir(os.path.join(package_dir, "i18n")):
os.chmod(
"trans.sh",
os.stat("trans.sh").st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH)
subprocess.check_call(f"./trans.sh {package_dir}", shell=True)


if __name__ == '__main__':
include_documentation('doc/_build/html', 'help/orange3-imageanalytics')
setup(
Expand Down Expand Up @@ -103,6 +131,9 @@ def include_documentation(local_dir, install_dir):
"requests_cache",
"scipy",
],
cmdclass={
'install': InstallMultilingualCommand,
},
extras_require={
'test': ['coverage', ],
'doc': ['sphinx', 'recommonmark', 'sphinx_rtd_theme', ],
Expand Down

0 comments on commit b918b43

Please sign in to comment.