Persian (Farsi) is a Right-to-Left language, but GUI is not changed

Hi,

Task Coach (http://www.taskcoach.org, developed using python and
wxPython) comes with different translations, some of which are RTL.
When the user selects Hebrew, the GUI is correctly switched to RTL as
well. However, when selecting Farsi, the GUI is not switched.

The locale is set as follows:

    def _setLocale(self, *localeStrings):
        for localeString in localeStrings:
            languageInfo = wx.Locale.FindLanguageInfo(localeString)
            if languageInfo:
                self.__locale = wx.Locale(languageInfo.Language)
                break

This method takes multiple localeStrings, because Task Coach first
tries the long form (e.g. "fa_IR") and then the short form ("fa") in
case the first didn't succeed.

So, my first question is: why does this work for Hebrew ("he_IL"), but
not for Farsi ("fa_IR")?

The second question is: can I work around this by explicitly setting
the layout direction? I know how to get the current layout direction:

def currentLanguageIsRightToLeft():
    return wx.GetApp().GetLayoutDirection() == wx.Layout_RightToLeft

and I know I can set the layout direction of individual windows:

window.SetLayoutDirection(wx.Layout_RightToLeft))

But doing this for every window including dialogs is a bit intrusive
for a work around.

Thanks, Frank

> So, my first question is: why does this work for Hebrew ("he_IL"), but
> not for Farsi ("fa_IR")?

I.e. Farsi is incorrectly marked as LTR instead of RTL. I've corrected it
now, thanks for reporting this problem.

Great to see this fixed, thanks.

> The second question is: can I work around this by explicitly setting
> the layout direction?

All windows inherit their default layout direction from wxApp, so calling
overriding wxApp::GetLayoutDirection() should work for C++ programs. I
don't know if you can do this from Python though.

A little experimenting suggests that simply overriding
GetLayoutDirection doesn't work in Python. I guess the windows don't
go through the Python-layer when invoking wxApp::GetLayoutDirection().

Thanks, Frank

···

2009/7/6 Vadim Zeitlin <vadim@wxwidgets.org>:

On Mon, 6 Jul 2009 21:30:00 +0200 Frank Niessink <frank@niessink.com> wrote:

Frank Niessink wrote:

···

2009/7/6 Vadim Zeitlin <vadim@wxwidgets.org>:

On Mon, 6 Jul 2009 21:30:00 +0200 Frank Niessink <frank@niessink.com> wrote:

> So, my first question is: why does this work for Hebrew ("he_IL"), but
> not for Farsi ("fa_IR")?

I.e. Farsi is incorrectly marked as LTR instead of RTL. I've corrected it
now, thanks for reporting this problem.

Great to see this fixed, thanks.

> The second question is: can I work around this by explicitly setting
> the layout direction?

All windows inherit their default layout direction from wxApp, so calling
overriding wxApp::GetLayoutDirection() should work for C++ programs. I
don't know if you can do this from Python though.

A little experimenting suggests that simply overriding
GetLayoutDirection doesn't work in Python. I guess the windows don't
go through the Python-layer when invoking wxApp::GetLayoutDirection().

Correct. That method hasn't been instrumented in the wxPython layers to allow redirecting the call to the Python class.

--
Robin Dunn
Software Craftsman