| Reference | Downloads | Github

Align Arabic typed response - language style RTL/Arabic doesn't work in textboxes

What did you try to make it work?:
I’m trying to run an experiment using textbox with Arabic language which follows right to left language style. I still got the Arabic letters written from left to right even when I changed the style to Arabic and RTL style.

In the English version of the study I used the following codes for as follows:

in begin experiment tab I have:

inputText3 = ""

In begin experiment tab:

inputText3 = ""
shift_flag = False

In each frame tab I have:

actualKeys = event.getKeys()
n = len(actualKeys)
i = 0
while i < n:
if actualKeys[i] == ‘return’:
continueRoutine = False
elif actualKeys[i] == ‘backspace’:
inputText3 = inputText3[:-1] # lose the final character
i = i + 1
elif actualKeys[i] == ‘space’:
inputText3 += ’ ’
i = i + 1
elif actualKeys[i] in [‘minus’, ‘-’, ‘num_subtract’, ‘Minus’, ‘slash’]:
inputText3 += ‘-’
i = i + 1
elif actualKeys[i] in [‘lshift’, ‘rshift’, ‘SHIFT’]:
shift_flag = True
i = i + 1
if len(actualKeys[i]) == 1:
if shift_flag:
inputText3 += actualKeys[i].upper()
shift_flag = False
inputText3 += actualKeys[i]
i = i + 1
In end routine tab:

thisExp.addData(“typedWord3”, inputText3)
inputText = ""

but these codes are not working at all in the Arabic version. I tried the text box and at least I got the Arabic letters displayed in the screen but in the wrong alignment (LTR).

I’m not sure if I need specific coding and whether or not there a way to make it using textbox?

Thank you

Python has a well known issue with Arabic. It can’t get the kerning right. The simplest work-around is to use a word processor to write the text you want to use as stimuli and convert them into images (just taking a screenshot will work if you don’t have access to a “cleaner” method). If you display them as images, they won’t be altered by Python’s text processing.
Good luck,

Hi Mark,

Thank you for your reply and suggestion. I’ve actually followed your suggested solution with the Arabic text I want to display on the screen, it works, thank you. However, I need to come up with a solution for text entries from participants, i.e. typing an Arabic script as a response to a question. I hope there’s a sort of trick that can make it happen :frowning: