Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Multilingual package and installation #6828

Merged
merged 7 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ recursive-include distribute *.svg *.desktop

include requirements*.txt

recursive-include i18n *.jaml *.yaml

include README.md
include README.pypi
include CONTRIBUTING.md
Expand Down
7 changes: 5 additions & 2 deletions Orange/widgets/data/owpreprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,12 @@ def createinstance(params):

def __repr__(self):
if self.__strategy == self.Fixed:
return f"select {self.__k} {pl(self.__k,'feature')}"
# private attributes may not appear translated strings
num = self.__k
return f"select {num} {pl(num,'feature')}"
else:
return f"select {self.__p} % features"
perc = self.__p
return f"select {perc} % features"


def index_to_enum(enum, i):
Expand Down
2 changes: 1 addition & 1 deletion conda-recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ requirements:
run:
- python
# GUI requirements
- orange-canvas-core >=0.2.0,<0.3a
- orange-canvas-core >=0.2.2,<0.3a
- orange-widget-base >=4.23.0
- anyqt >=0.2.0
- pyqt >=5.12,!=5.15.1,<6.0
Expand Down
120 changes: 69 additions & 51 deletions i18n/si/msgs.jaml

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions i18n/si/trubar-config.yaml

This file was deleted.

10 changes: 4 additions & 6 deletions i18n/trans.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
if [ "$#" -ne 2 ]
if [ "$#" -ne 1 ]
then
echo "trans <language> <destination>"
echo "trans <destination>"
exit
else
lang=$1
dest=$2
trubar --conf $lang/trubar-config.yaml translate -s ../Orange -d $dest/Orange --static $lang/static $lang/msgs.jaml
trubar --conf $lang/tests-config.yaml translate -s ../Orange -d $dest/Orange $lang/tests-msgs.jaml
dest=$1
trubar --conf trubar-config.yaml translate -s ../Orange -d $dest/Orange msgs.jaml
fi
10 changes: 10 additions & 0 deletions i18n/trans1.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
if [ "$#" -ne 2 ]
then
echo "trans <language> <destination>"
exit
else
lang=$1
dest=$2
trubar --conf $lang/trubar-config.yaml translate -s ../Orange -d $dest/Orange --static $lang/static $lang/msgs.jaml
trubar --conf $lang/tests-config.yaml translate -s ../Orange -d $dest/Orange $lang/tests-msgs.jaml
fi
13 changes: 13 additions & 0 deletions i18n/trubar-config.yaml
Original file line number Diff line number Diff line change
@@ -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("Orange", "biolab.si", "Orange")
del Translator
encoding: "utf-8"
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ requires = [
"setuptools>=51.0",
"sphinx",
"wheel",
"trubar>=0.3.4"
]

build-backend = "setuptools.build_meta"
Expand Down
2 changes: 1 addition & 1 deletion requirements-gui.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
orange-canvas-core>=0.2a,<0.3a
orange-canvas-core>=0.2.2,<0.3a
orange-widget-base>=4.23.0

AnyQt>=0.2.0
Expand Down
16 changes: 16 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import sys
import subprocess
from setuptools import setup, find_packages, Command
from setuptools.command.install import install

from distutils.command import install_data, sdist
from distutils.command.build_ext import build_ext
from distutils.command import config, build
from distutils.core import Extension

from trubar import translate

try:
import numpy
Expand Down Expand Up @@ -473,9 +475,23 @@ def ext_modules():
return modules


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

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


def setup_package():
write_version_py()
cmdclass = {
'install': InstallMultilingualCommand,
'lint': LintCommand,
'coverage': CoverageCommand,
'config': config,
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ deps =
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
# GUI requirements
oldest: orange-canvas-core==0.2.0
oldest: orange-canvas-core==0.2.2
oldest: orange-widget-base==4.23.0
oldest: AnyQt==0.2.0
oldest: matplotlib==3.2.0
Expand Down
Loading