From 6316de5ad68d6120f3c3a89aac08df92d94b2277 Mon Sep 17 00:00:00 2001 From: Amr Barghouthi Date: Sat, 5 Dec 2020 10:07:07 +0200 Subject: [PATCH 1/3] Adding mirror property to RecolorImage --- UM/Qt/qml/UM/RecolorImage.qml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UM/Qt/qml/UM/RecolorImage.qml b/UM/Qt/qml/UM/RecolorImage.qml index 5bd73a6b54..da136de640 100644 --- a/UM/Qt/qml/UM/RecolorImage.qml +++ b/UM/Qt/qml/UM/RecolorImage.qml @@ -12,6 +12,7 @@ Item property alias source: img.source property alias color: overlay.color property alias sourceSize: img.sourceSize + property alias mirror: img.mirror Image { @@ -20,6 +21,7 @@ Item visible: false sourceSize.width: parent.width sourceSize.height: parent.height + layer.enabled: true } ColorOverlay { From d93af3baff31e058951738ae4d00ffc55470d2e4 Mon Sep 17 00:00:00 2001 From: Amr Barghouthi Date: Mon, 7 Dec 2020 16:46:52 +0200 Subject: [PATCH 2/3] A function to indicate if the language is right to left --- UM/Qt/Bindings/i18nCatalogProxy.py | 9 +++++++++ UM/i18n.py | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/UM/Qt/Bindings/i18nCatalogProxy.py b/UM/Qt/Bindings/i18nCatalogProxy.py index 86a5eaa6d3..cc8b18e9c6 100644 --- a/UM/Qt/Bindings/i18nCatalogProxy.py +++ b/UM/Qt/Bindings/i18nCatalogProxy.py @@ -23,6 +23,7 @@ def __init__(self, parent = None): self._i18nc_function = self._wrapFunction(engine, self, self._call_i18nc) self._i18np_function = self._wrapFunction(engine, self, self._call_i18np) self._i18ncp_function = self._wrapFunction(engine, self, self._call_i18ncp) + self._i18nIsRightToLeft_function = self._wrapFunction(engine, self, self._call_i18nIsRightToLeft) def setName(self, name): if name != self._name: @@ -51,6 +52,10 @@ def i18np(self): def i18ncp(self): return self._i18ncp_function + @pyqtProperty(QJSValue, notify = nameChanged) + def i18nIsRightToLeft(self): + return self._i18nIsRightToLeft_function + @pyqtSlot(str, result = str) def _call_i18n(self, message): return self._catalog.i18n(message) @@ -67,6 +72,10 @@ def _call_i18np(self, single, multiple, counter): def _call_i18ncp(self, context, single, multiple, counter): return self._catalog.i18ncp(context, single, multiple, counter) + @pyqtSlot(result= bool) + def _call_i18nIsRightToLeft(self): + return self._catalog.i18nIsRightToLeft() + def _wrapFunction(self, engine, this_object, function): """Wrap a function in a bit of a javascript to re-trigger a method call on signal emit. diff --git a/UM/i18n.py b/UM/i18n.py index 02ce748d57..003cf5c1cb 100644 --- a/UM/i18n.py +++ b/UM/i18n.py @@ -173,6 +173,18 @@ def i18ncp(self, context: str, single: str, multiple: str, counter: int, *args: translated = translated.format(counter, args) return self._replaceTags(translated) + def i18nIsRightToLeft(self): + """Returns true if the language is right to left language. + + it uses the following message in the language file + msgctxt "@language:direction" + msgid "ltr" + msgstr "rtl + + :return: True if the language is right to left otherwise False + """ + return self.i18nc("@language:direction","ltr")=="rtl" + def _replaceTags(self, string: str) -> str: """Replace formatting tags in the string with globally-defined replacement values. From 993959435be726d726d31603d8aec7fdd8d3e9ba Mon Sep 17 00:00:00 2001 From: Amr Barghouthi Date: Tue, 8 Dec 2020 16:10:20 +0200 Subject: [PATCH 3/3] Using language metadata to detrmine insted of a message --- UM/i18n.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/UM/i18n.py b/UM/i18n.py index 003cf5c1cb..a95665ff5a 100644 --- a/UM/i18n.py +++ b/UM/i18n.py @@ -176,14 +176,14 @@ def i18ncp(self, context: str, single: str, multiple: str, counter: int, *args: def i18nIsRightToLeft(self): """Returns true if the language is right to left language. - it uses the following message in the language file - msgctxt "@language:direction" - msgid "ltr" - msgstr "rtl - + It uses the variable Language-Direction in the language metadata to detrmine direction + if direction not specified it will default to false + :return: True if the language is right to left otherwise False """ - return self.i18nc("@language:direction","ltr")=="rtl" + if(self.__translation is not None): + return self.__translation.info().get("Language-Direction","ltr")=="rtl" + return False def _replaceTags(self, string: str) -> str: """Replace formatting tags in the string with globally-defined replacement