biolab / orange-canvas-core

Orange Canvas core workflow editor
GNU General Public License v3.0
33 stars 60 forks source link

Add language setting and translation function #296

Closed janezd closed 1 month ago

janezd commented 2 months ago

This adds a language selector to the settings dialog. It will allow us to prepare multilingual distributions of Orange, which we urgently need for various education-related projects.

The change is only visible if distribution includes message files that are prepared by (so far unpublished new version of) Trubar.

Caveats:

@ales-erjavec, do you have any comments?


To do:


I'm attaching examples of core files and some add-ons. Strings are simply looked up in a table, e.g.

        gui.button(box, self, "Save", callback=self.save)
        gui.button(box, self, "Load", callback=self.load)
        gui.button(box, self, "Reset", callback=self.reset)

becomes

        gui.button(box, self, _tr.m[233], callback=self.save)
        gui.button(box, self, _tr.m[234], callback=self.load)
        gui.button(box, self, _tr.m[235], callback=self.reset)

while f-strings, like

            tpe = f"Random sample with {self.sampleSizePercentage} % of data"

are compiled and evaluated,

            tpe = _tr.e(_tr.c(573))

m, c and e are attributes of Translator class from this PR.

orange3.zip orange-canvas-core.zip orange-widget-base.zip orange3-imageanalytics.zip orange3-geo.zip orange3-network.zip

Preparation of these files is not a part of this PR.

codecov-commenter commented 2 months ago

Codecov Report

Attention: Patch coverage is 56.36364% with 24 lines in your changes are missing coverage. Please review.

Project coverage is 76.61%. Comparing base (8a3ecf1) to head (352808d).

Files Patch % Lines
orangecanvas/utils/localization/__init__.py 64.86% 13 Missing :warning:
orangecanvas/application/settings.py 23.07% 10 Missing :warning:
orangecanvas/main.py 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #296 +/- ## ========================================== - Coverage 76.67% 76.61% -0.06% ========================================== Files 99 99 Lines 21104 21158 +54 ========================================== + Hits 16181 16210 +29 - Misses 4923 4948 +25 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.