Skip to content

Commit

Permalink
Setup: Add translation if trubar is available
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Sep 2, 2024
1 parent d3d2588 commit 28ddfe3
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#! /usr/bin/env python
import os

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


NAME = "orange-canvas-core"
VERSION = "0.2.3.dev0"
Expand Down Expand Up @@ -62,6 +66,25 @@

PYTHON_REQUIRES = ">=3.8"


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

def compile_to_multilingual(self):
try:
from trubar import translate
except ImportError:
return

package_dir = os.path.dirname(os.path.abspath(__file__))
translate(
"msgs.jaml",
source_dir=os.path.join(self.install_lib, "orangecanvas"),
config_file=os.path.join(package_dir, "i18n", "trubar-config.yaml"))


if __name__ == "__main__":
setup(
name=NAME,
Expand All @@ -76,6 +99,9 @@
packages=PACKAGES,
package_data=PACKAGE_DATA,
install_requires=INSTALL_REQUIRES,
cmdclass={
'install': InstallMultilingualCommand,
},
extras_require=EXTRAS_REQUIRE,
project_urls=PROJECT_URLS,
python_requires=PYTHON_REQUIRES,
Expand Down

0 comments on commit 28ddfe3

Please sign in to comment.