From 073ff876988203200486ffdbbc5bfb8824247051 Mon Sep 17 00:00:00 2001 From: janezd Date: Tue, 11 Jun 2024 13:37:03 +0200 Subject: [PATCH] Multilingual --- MANIFEST.in | 1 + i18n/si/trubar-config.yaml | 2 -- i18n/trans.sh | 9 ++++----- i18n/trubar-config.yaml | 13 +++++++++++++ setup.py | 26 +++++++++++++++++++++++--- tox.ini | 8 ++++---- 6 files changed, 45 insertions(+), 14 deletions(-) delete mode 100644 i18n/si/trubar-config.yaml create mode 100644 i18n/trubar-config.yaml diff --git a/MANIFEST.in b/MANIFEST.in index 4b5bea7..839b016 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,3 +2,4 @@ recursive-include doc *.bat *.json *.md *.png *.py *.rst Makefile recursive-include orangecontrib *.csv *.json *.sh *.svg *.txt + recursive-include i18n *.jaml *.yaml diff --git a/i18n/si/trubar-config.yaml b/i18n/si/trubar-config.yaml deleted file mode 100644 index 2d1c8ff..0000000 --- a/i18n/si/trubar-config.yaml +++ /dev/null @@ -1,2 +0,0 @@ -auto-import: "from orangecanvas.utils.localization.si import plsi, plsi_sz, z_besedo # pylint: disable=wrong-import-order" -encoding: "utf-8" diff --git a/i18n/trans.sh b/i18n/trans.sh index 85d2bc9..1b5e902 100755 --- a/i18n/trans.sh +++ b/i18n/trans.sh @@ -1,8 +1,7 @@ -if [ "$#" -ne 2 ] +if [ "$#" -ne 1 ] then - echo "Usage: trans " + echo "Usage: trans " else - lang=$1 - dest=$2 - trubar --conf $lang/trubar-config.yaml translate -s ../orangecontrib/geo -d $dest/orangecontrib/geo $lang/msgs.jaml + dest=$1 + trubar --conf trubar-config.yaml translate -s ../orangecontrib/geo -d $dest/orangecontrib/geo msgs.jaml fi diff --git a/i18n/trubar-config.yaml b/i18n/trubar-config.yaml new file mode 100644 index 0000000..f31b182 --- /dev/null +++ b/i18n/trubar-config.yaml @@ -0,0 +1,13 @@ +languages: + en: + name: English + original: true + si: + name: Slovenščina + international-name: Slovenian + auto-import: from orangecanvas.utils.localization.si import plsi, plsi_sz, z_besedo # pylint: disable=wrong-import-order +auto-import: |2 + from orangecanvas.utils.localization import Translator # pylint: disable=wrong-import-order + _tr = Translator("orangecontrib.geo", "biolab.si", "Orange") + del Translator +encoding: "utf-8" \ No newline at end of file diff --git a/setup.py b/setup.py index f0a25b2..f98e183 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from os import path from setuptools import setup, find_packages - +from setuptools.command.install import install VERSION = "0.4.2" @@ -36,6 +36,21 @@ def _discover_tests(): top_level_dir='.') +class InstallMultilingualCommand(install): + def run(self): + install.run(self) + self.compile_to_multilingual() + + def compile_to_multilingual(self): + from trubar import translate + + package_dir = path.dirname(path.abspath(__file__)) + translate( + "msgs.jaml", + source_dir=path.join(self.install_lib, "orangecontrib", "geo"), + config_file=path.join(package_dir, "i18n", "trubar-config.yaml")) + + if __name__ == '__main__': setup( name='Orange3-Geo', @@ -47,7 +62,7 @@ def _discover_tests(): packages=find_packages(), include_package_data=True, install_requires=[ - 'Orange3>=3.34.0', + 'Orange3>=3.37.0', 'scikit-learn', 'pandas', 'scipy>=0.17', @@ -56,7 +71,12 @@ def _discover_tests(): 'simplejson', 'Pillow' ], - + setup_requires=[ + 'trubar>=0.3.3', + ], + cmdclass={ + 'install': InstallMultilingualCommand, + }, extras_require = { 'test': ['coverage'], 'doc': ['sphinx', 'recommonmark', 'sphinx_rtd_theme'], diff --git a/tox.ini b/tox.ini index 6d5a09b..2f50d59 100644 --- a/tox.ini +++ b/tox.ini @@ -23,11 +23,11 @@ deps = {env:PYQT_PYPI_NAME:PyQt5}=={env:PYQT_PYPI_VERSION:5.15.*} {env:WEBENGINE_PYPI_NAME:PyQtWebEngine}=={env:WEBENGINE_PYPI_VERSION:5.15.*} oldest: numpy~=1.22.0 # some older version - oldest: orange3==3.34.0 - oldest: orange-canvas-core==0.1.28 - oldest: orange-widget-base==4.19.0 + oldest: orange3==3.37.0 + oldest: orange-canvas-core>=0.2.2, + oldest: orange-widget-base>=4.23.0, oldest: pandas==1.4.0 - oldest: scikit-learn~=1.0.1 + oldest: scikit-learn~=1.3.0 latest: https://github.com/biolab/orange3/archive/refs/heads/master.zip#egg=orange3 latest: https://github.com/biolab/orange-canvas-core/archive/refs/heads/master.zip#egg=orange-canvas-core latest: https://github.com/biolab/orange-widget-base/archive/refs/heads/master.zip#egg=orange-widget-base